@azrico/azcli 1.2.3 → 1.2.5
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/README.md +5 -0
- package/dist/cli/create-cli.js +37 -0
- package/dist/cli/create-cli.js.map +1 -0
- package/dist/cli/index.js +23 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/options.js +17 -0
- package/dist/cli/options.js.map +1 -0
- package/dist/core/files.js +82 -0
- package/dist/core/files.js.map +1 -0
- package/dist/core/json.js +16 -0
- package/dist/core/json.js.map +1 -0
- package/dist/core/logger.js +26 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/process.js +125 -0
- package/dist/core/process.js.map +1 -0
- package/dist/core/project-type.js +41 -0
- package/dist/core/project-type.js.map +1 -0
- package/dist/core/strings.js +20 -0
- package/dist/core/strings.js.map +1 -0
- package/dist/features/build/build.js +46 -0
- package/dist/features/build/build.js.map +1 -0
- package/dist/features/build/command.js +17 -0
- package/dist/features/build/command.js.map +1 -0
- package/dist/features/build/wordpress.js +135 -0
- package/dist/features/build/wordpress.js.map +1 -0
- package/dist/features/clean/clean.js +27 -0
- package/dist/features/clean/clean.js.map +1 -0
- package/dist/features/clean/command.js +13 -0
- package/dist/features/clean/command.js.map +1 -0
- package/dist/features/optimize-transcripts/agent-runner.js +40 -0
- package/dist/features/optimize-transcripts/agent-runner.js.map +1 -0
- package/dist/features/optimize-transcripts/command.js +24 -0
- package/dist/features/optimize-transcripts/command.js.map +1 -0
- package/dist/features/optimize-transcripts/optimize.js +72 -0
- package/dist/features/optimize-transcripts/optimize.js.map +1 -0
- package/dist/features/optimize-transcripts/prompts.js +39 -0
- package/dist/features/optimize-transcripts/prompts.js.map +1 -0
- package/dist/features/optimize-transcripts/redact.js +57 -0
- package/dist/features/optimize-transcripts/redact.js.map +1 -0
- package/dist/features/optimize-transcripts/secret-remover.js +85 -0
- package/dist/features/optimize-transcripts/secret-remover.js.map +1 -0
- package/dist/features/package/command.js +13 -0
- package/dist/features/package/command.js.map +1 -0
- package/dist/features/package/packager.js +132 -0
- package/dist/features/package/packager.js.map +1 -0
- package/dist/features/publish/command.js +13 -0
- package/dist/features/publish/command.js.map +1 -0
- package/dist/features/publish/publish.js +29 -0
- package/dist/features/publish/publish.js.map +1 -0
- package/dist/features/transcripts/command.js +27 -0
- package/dist/features/transcripts/command.js.map +1 -0
- package/dist/features/transcripts/extract.js +148 -0
- package/dist/features/transcripts/extract.js.map +1 -0
- package/dist/features/transcripts/jsonl.js +100 -0
- package/dist/features/transcripts/jsonl.js.map +1 -0
- package/dist/features/transcripts/options.js +53 -0
- package/dist/features/transcripts/options.js.map +1 -0
- package/dist/features/transcripts/render-markdown.js +105 -0
- package/dist/features/transcripts/render-markdown.js.map +1 -0
- package/dist/features/transcripts/sources/claude.js +150 -0
- package/dist/features/transcripts/sources/claude.js.map +1 -0
- package/dist/features/transcripts/sources/codex.js +171 -0
- package/dist/features/transcripts/sources/codex.js.map +1 -0
- package/dist/features/transcripts/types.js +5 -0
- package/dist/features/transcripts/types.js.map +1 -0
- package/dist/features/update/command.js +16 -0
- package/dist/features/update/command.js.map +1 -0
- package/dist/features/update/composer.js +35 -0
- package/dist/features/update/composer.js.map +1 -0
- package/dist/features/update/filter-options.js +23 -0
- package/dist/features/update/filter-options.js.map +1 -0
- package/dist/features/update/update.js +28 -0
- package/dist/features/update/update.js.map +1 -0
- package/dist/features/update/yarn.js +30 -0
- package/dist/features/update/yarn.js.map +1 -0
- package/dist/features/verify-changes/changed-files.js +36 -0
- package/dist/features/verify-changes/changed-files.js.map +1 -0
- package/dist/features/verify-changes/command.js +27 -0
- package/dist/features/verify-changes/command.js.map +1 -0
- package/dist/features/verify-changes/config.js +91 -0
- package/dist/features/verify-changes/config.js.map +1 -0
- package/dist/features/verify-changes/report.js +30 -0
- package/dist/features/verify-changes/report.js.map +1 -0
- package/dist/features/verify-changes/select.js +39 -0
- package/dist/features/verify-changes/select.js.map +1 -0
- package/dist/features/verify-changes/verify.js +54 -0
- package/dist/features/verify-changes/verify.js.map +1 -0
- package/dist/features/worktree/command.js +55 -0
- package/dist/features/worktree/command.js.map +1 -0
- package/dist/features/worktree/config.js +115 -0
- package/dist/features/worktree/config.js.map +1 -0
- package/dist/features/worktree/git.js +62 -0
- package/dist/features/worktree/git.js.map +1 -0
- package/dist/features/worktree/start.js +156 -0
- package/dist/features/worktree/start.js.map +1 -0
- package/dist/features/worktree/status.js +50 -0
- package/dist/features/worktree/status.js.map +1 -0
- package/dist/features/worktree/sync.js +107 -0
- package/dist/features/worktree/sync.js.map +1 -0
- package/dist/features/yarn/commands.js +18 -0
- package/dist/features/yarn/commands.js.map +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.writeSession = void 0;
|
|
7
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
8
|
+
const node_stream_1 = require("node:stream");
|
|
9
|
+
const promises_1 = require("node:stream/promises");
|
|
10
|
+
const jsonl_1 = require("./jsonl");
|
|
11
|
+
const options_1 = require("./options");
|
|
12
|
+
function fence(text, lang = '') {
|
|
13
|
+
const longest = Math.max(2, ...(text.match(/`+/g) ?? []).map((s) => s.length));
|
|
14
|
+
const f = '`'.repeat(longest + 1);
|
|
15
|
+
return `${f}${lang}\n${text}\n${f}\n\n`;
|
|
16
|
+
}
|
|
17
|
+
function fenceTruncated(text, lang = '') {
|
|
18
|
+
if (text.length <= options_1.max_tool_chars)
|
|
19
|
+
return fence(text, lang);
|
|
20
|
+
const cut = text.length - options_1.max_tool_chars;
|
|
21
|
+
return fence(text.slice(0, options_1.max_tool_chars), lang) + `_[truncated ${cut} chars]_\n\n`;
|
|
22
|
+
}
|
|
23
|
+
function quote(text) {
|
|
24
|
+
return '> _thinking_\n>\n' + text.split('\n').map((l) => '> ' + l).join('\n') + '\n\n';
|
|
25
|
+
}
|
|
26
|
+
function renderHeader(info) {
|
|
27
|
+
return [
|
|
28
|
+
`# ${info.summary || info.sessionId}`,
|
|
29
|
+
'',
|
|
30
|
+
`- **Session:** ${info.sessionId}`,
|
|
31
|
+
`- **Summary:** ${info.summary || '-'}`,
|
|
32
|
+
`- **cwd:** ${info.cwd || '-'}`,
|
|
33
|
+
`- **Branch:** ${info.gitBranch || '-'}`,
|
|
34
|
+
`- **Started:** ${info.started || '-'}`,
|
|
35
|
+
`- **Ended:** ${info.ended || '-'}`,
|
|
36
|
+
'',
|
|
37
|
+
'---',
|
|
38
|
+
'',
|
|
39
|
+
].join('\n');
|
|
40
|
+
}
|
|
41
|
+
async function* renderMessages(source, files, opts) {
|
|
42
|
+
const toolNames = new Map();
|
|
43
|
+
let lastKey = '';
|
|
44
|
+
let n = 0;
|
|
45
|
+
const heading = (key, title, e) => {
|
|
46
|
+
if (key === lastKey)
|
|
47
|
+
return '';
|
|
48
|
+
lastKey = key;
|
|
49
|
+
const sub = e.sidechain ? ' (subagent)' : '';
|
|
50
|
+
return `\n## ${title}${sub}${e.timestamp ? ' — ' + e.timestamp : ''}\n\n`;
|
|
51
|
+
};
|
|
52
|
+
for await (const e of (0, jsonl_1.mergeByTime)((0, jsonl_1.sessionEntries)(source, files))) {
|
|
53
|
+
if (e.sidechain && !opts.includeSubagents)
|
|
54
|
+
continue;
|
|
55
|
+
const entryKey = `r${n++}`;
|
|
56
|
+
let md = '';
|
|
57
|
+
for (const p of e.parts) {
|
|
58
|
+
const partKey = `${entryKey}:${p.toolId ?? ''}`;
|
|
59
|
+
const groupKey = `g:${p.group ?? entryKey}`;
|
|
60
|
+
switch (p.kind) {
|
|
61
|
+
case 'user':
|
|
62
|
+
if (opts.userOnly && e.sidechain)
|
|
63
|
+
break;
|
|
64
|
+
md += heading(partKey, 'User', e) + p.text + '\n\n';
|
|
65
|
+
break;
|
|
66
|
+
case 'assistant':
|
|
67
|
+
if (opts.userOnly)
|
|
68
|
+
break;
|
|
69
|
+
md += heading(groupKey, 'Assistant', e) + p.text + '\n\n';
|
|
70
|
+
break;
|
|
71
|
+
case 'thinking':
|
|
72
|
+
if (opts.userOnly || !opts.includeThinking)
|
|
73
|
+
break;
|
|
74
|
+
md += heading(groupKey, 'Assistant', e) + quote(p.text);
|
|
75
|
+
break;
|
|
76
|
+
case 'tool_call':
|
|
77
|
+
if (p.toolId && p.toolName)
|
|
78
|
+
toolNames.set(p.toolId, p.toolName);
|
|
79
|
+
if (opts.userOnly || !opts.includeTools)
|
|
80
|
+
break;
|
|
81
|
+
md += heading(partKey, `Tool (${p.toolName} call)`, e);
|
|
82
|
+
md += fenceTruncated(p.text, p.lang);
|
|
83
|
+
break;
|
|
84
|
+
case 'tool_result': {
|
|
85
|
+
if (opts.userOnly || !opts.includeTools)
|
|
86
|
+
break;
|
|
87
|
+
const name = toolNames.get(p.toolId ?? '') ?? 'unknown';
|
|
88
|
+
md += heading(partKey, `Tool (${name} result${p.isError ? ', error' : ''})`, e);
|
|
89
|
+
md += fenceTruncated(p.text, p.lang);
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
yield md;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
async function writeSession(target, source, files, info, opts) {
|
|
98
|
+
async function* chunks() {
|
|
99
|
+
yield renderHeader(info);
|
|
100
|
+
yield* renderMessages(source, files, opts);
|
|
101
|
+
}
|
|
102
|
+
await (0, promises_1.pipeline)(node_stream_1.Readable.from(chunks()), node_fs_1.default.createWriteStream(target, { encoding: 'utf8' }));
|
|
103
|
+
}
|
|
104
|
+
exports.writeSession = writeSession;
|
|
105
|
+
//# sourceMappingURL=render-markdown.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-markdown.js","sourceRoot":"","sources":["../../../src/features/transcripts/render-markdown.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ACvD,EAAE,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;oBACrC,MAAM;gBACP,KAAK,aAAa,CAAC,CAAC;oBACnB,IAAI,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY;wBAAE,MAAM;oBAC/C,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,IAAI,SAAS,CAAC;oBACxD,EAAE,IAAI,OAAO,CAAC,OAAO,EAAE,SAAS,IAAI,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;oBAChF,EAAE,IAAI,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;oBACrC,MAAM;iBACN;aACD;SACD;QACD,MAAM,EAAE,CAAC;KACT;AACF,CAAC;AAEM,KAAK,UAAU,YAAY,CACjC,MAAc,EACd,MAAwB,EACxB,KAAe,EACf,IAAiB,EACjB,IAAa;IAEb,KAAK,SAAS,CAAC,CAAC,MAAM;QACrB,MAAM,YAAY,CAAC,IAAI,CAAC,CAAC;QACzB,KAAK,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,MAAM,IAAA,mBAAQ,EAAC,sBAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,iBAAE,CAAC,iBAAiB,CAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAC7F,CAAC;AAZD,oCAYC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Reads Claude Code session transcripts (~/.claude/projects/<folder>/<session-id>.jsonl) */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.claude_source = exports.createClaudeSource = void 0;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const jsonl_1 = require("../jsonl");
|
|
12
|
+
const json_1 = require("../../../core/json");
|
|
13
|
+
const projects_dir = node_path_1.default.join(process.env.CLAUDE_CONFIG_DIR || node_path_1.default.join(node_os_1.default.homedir(), '.claude'), 'projects');
|
|
14
|
+
/* -------------------------------------------------------------------------- */
|
|
15
|
+
/* Listing */
|
|
16
|
+
/* -------------------------------------------------------------------------- */
|
|
17
|
+
function listSessionFiles(projectDir) {
|
|
18
|
+
return node_fs_1.default
|
|
19
|
+
.readdirSync(projectDir, { withFileTypes: true })
|
|
20
|
+
.filter((e) => e.isFile() && e.name.endsWith('.jsonl'))
|
|
21
|
+
.map((e) => {
|
|
22
|
+
const file = node_path_1.default.join(projectDir, e.name);
|
|
23
|
+
const sessionId = node_path_1.default.basename(e.name, '.jsonl');
|
|
24
|
+
return { sessionId, file, mtime: node_fs_1.default.statSync(file).mtimeMs };
|
|
25
|
+
})
|
|
26
|
+
.sort((a, b) => a.mtime - b.mtime);
|
|
27
|
+
}
|
|
28
|
+
/** Subagent transcripts are stored in <session-id>/subagents/ */
|
|
29
|
+
function listSubagentFiles(projectDir, sessionId) {
|
|
30
|
+
const dir = node_path_1.default.join(projectDir, sessionId, 'subagents');
|
|
31
|
+
if (!node_fs_1.default.existsSync(dir))
|
|
32
|
+
return [];
|
|
33
|
+
return node_fs_1.default
|
|
34
|
+
.readdirSync(dir)
|
|
35
|
+
.filter((f) => f.endsWith('.jsonl'))
|
|
36
|
+
.map((f) => node_path_1.default.join(dir, f));
|
|
37
|
+
}
|
|
38
|
+
/** First `cwd` found in the given session files */
|
|
39
|
+
async function findCwd(files) {
|
|
40
|
+
for (const f of files) {
|
|
41
|
+
for await (const rec of (0, jsonl_1.readJsonl)(f)) {
|
|
42
|
+
if (rec.cwd)
|
|
43
|
+
return String(rec.cwd);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return '';
|
|
47
|
+
}
|
|
48
|
+
async function listProjects(root) {
|
|
49
|
+
const folders = node_fs_1.default
|
|
50
|
+
.readdirSync(root, { withFileTypes: true })
|
|
51
|
+
.filter((e) => e.isDirectory())
|
|
52
|
+
.map((e) => e.name);
|
|
53
|
+
const projects = [];
|
|
54
|
+
for (const folder of folders) {
|
|
55
|
+
const projectDir = node_path_1.default.join(root, folder);
|
|
56
|
+
const files = listSessionFiles(projectDir);
|
|
57
|
+
if (files.length === 0)
|
|
58
|
+
continue;
|
|
59
|
+
projects.push({
|
|
60
|
+
folder,
|
|
61
|
+
cwd: await findCwd(files.map((s) => s.file)),
|
|
62
|
+
sessions: files.map((s) => ({ ...s, subFiles: listSubagentFiles(projectDir, s.sessionId) })),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return projects;
|
|
66
|
+
}
|
|
67
|
+
/* -------------------------------------------------------------------------- */
|
|
68
|
+
/* Records */
|
|
69
|
+
/* -------------------------------------------------------------------------- */
|
|
70
|
+
const system_prefixes = ['<task-notification', '<local-command-stdout', '<local-command-stderr'];
|
|
71
|
+
function contentBlocks(rec) {
|
|
72
|
+
const c = rec.message?.content;
|
|
73
|
+
if (typeof c === 'string')
|
|
74
|
+
return [{ type: 'text', text: c }];
|
|
75
|
+
return Array.isArray(c) ? c.filter((block) => (0, json_1.isRecord)(block) && typeof block.type === 'string') : [];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Text typed by a user: a non-meta user record with a text block that isn't a system notice.
|
|
79
|
+
* Tool results also arrive as "user" records, but never carry text blocks.
|
|
80
|
+
* On sidechain records the "user" is the parent agent.
|
|
81
|
+
*/
|
|
82
|
+
function isHumanText(rec) {
|
|
83
|
+
if (rec.type !== 'user' || rec.isMeta || rec.isCompactSummary)
|
|
84
|
+
return false;
|
|
85
|
+
const texts = contentBlocks(rec).filter((b) => b.type === 'text');
|
|
86
|
+
if (texts.length === 0)
|
|
87
|
+
return false;
|
|
88
|
+
return !texts.every((b) => system_prefixes.some((p) => (b.text ?? '').trimStart().startsWith(p)));
|
|
89
|
+
}
|
|
90
|
+
function userText(blocks) {
|
|
91
|
+
return blocks
|
|
92
|
+
.map((b) => (b.type === 'text' ? b.text ?? '' : b.type === 'image' ? '_[image]_' : ''))
|
|
93
|
+
.filter((t) => t.length > 0)
|
|
94
|
+
.join('\n\n');
|
|
95
|
+
}
|
|
96
|
+
async function* readEntries(file, isSubFile) {
|
|
97
|
+
for await (const value of (0, jsonl_1.readJsonl)(file)) {
|
|
98
|
+
if (typeof value.type !== 'string')
|
|
99
|
+
continue;
|
|
100
|
+
const rec = value;
|
|
101
|
+
const e = {
|
|
102
|
+
timestamp: (0, json_1.asString)(rec.timestamp),
|
|
103
|
+
sidechain: isSubFile || !!rec.isSidechain,
|
|
104
|
+
cwd: (0, json_1.asString)(rec.cwd),
|
|
105
|
+
gitBranch: (0, json_1.asString)(rec.gitBranch),
|
|
106
|
+
parts: [],
|
|
107
|
+
};
|
|
108
|
+
if (rec.customTitle)
|
|
109
|
+
e.title = { text: rec.customTitle, rank: 3 };
|
|
110
|
+
else if (rec.type === 'summary' && rec.summary)
|
|
111
|
+
e.title = { text: rec.summary, rank: 2 };
|
|
112
|
+
else if (rec.aiTitle)
|
|
113
|
+
e.title = { text: rec.aiTitle, rank: 1 };
|
|
114
|
+
if (!rec.isMeta && rec.type === 'user') {
|
|
115
|
+
const blocks = contentBlocks(rec);
|
|
116
|
+
if (isHumanText(rec))
|
|
117
|
+
e.parts.push({ kind: 'user', text: userText(blocks) });
|
|
118
|
+
for (const b of blocks) {
|
|
119
|
+
if (b.type !== 'tool_result')
|
|
120
|
+
continue;
|
|
121
|
+
const text = (0, jsonl_1.blocksText)(b.content);
|
|
122
|
+
e.parts.push({ kind: 'tool_result', text, toolId: b.tool_use_id, isError: b.is_error });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (!rec.isMeta && rec.type === 'assistant') {
|
|
126
|
+
const group = rec.message?.id;
|
|
127
|
+
for (const b of contentBlocks(rec)) {
|
|
128
|
+
if (b.type === 'text' && b.text)
|
|
129
|
+
e.parts.push({ kind: 'assistant', text: b.text, group });
|
|
130
|
+
else if (b.type === 'thinking' && b.thinking)
|
|
131
|
+
e.parts.push({ kind: 'thinking', text: b.thinking, group });
|
|
132
|
+
else if (b.type === 'tool_use')
|
|
133
|
+
e.parts.push({
|
|
134
|
+
kind: 'tool_call',
|
|
135
|
+
text: JSON.stringify(b.input ?? {}, null, 2),
|
|
136
|
+
toolName: b.name,
|
|
137
|
+
toolId: b.id,
|
|
138
|
+
lang: 'json',
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
yield e;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
function createClaudeSource(root) {
|
|
146
|
+
return { name: 'claude', root, listProjects: () => listProjects(root), readEntries };
|
|
147
|
+
}
|
|
148
|
+
exports.createClaudeSource = createClaudeSource;
|
|
149
|
+
exports.claude_source = createClaudeSource(projects_dir);
|
|
150
|
+
//# sourceMappingURL=claude.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../../../../src/features/transcripts/sources/claude.ts"],"names":[],"mappings":";AAAA,4FAA4F;;;;;;AAE5F,sDAAyB;AACzB,sDAAyB;AACzB,0DAA6B;AAC7B,oCAAiD;AAEjD,6CAAwD;AA2BxD,MAAM,YAAY,GAAG,mBAAI,CAAC,IAAI,CAC7B,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,mBAAI,CAAC,IAAI,CAAC,iBAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,EACnE,UAAU,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I,EAAE,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;qBACrF,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU,IAAI,CAAC,CAAC,QAAQ;oBAC3C,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;qBACxD,IAAI,CAAC,CAAC,IAAI,KAAK,UAAU;oBAC7B,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;wBACZ,IAAI,EAAE,WAAW;wBACjB,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;wBAC5C,QAAQ,EAAE,CAAC,CAAC,IAAI;wBAChB,MAAM,EAAE,CAAC,CAAC,EAAE;wBACZ,IAAI,EAAE,MAAM;qBACZ,CAAC,CAAC;aACJ;SACD;QACD,MAAM,CAAC,CAAC;KACR;AACF,CAAC;AAED,SAAgB,kBAAkB,CAAC,IAAY;IAC9C,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;AACtF,CAAC;AAFD,gDAEC;AAEY,QAAA,aAAa,GAAG,kBAAkB,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Reads Codex session transcripts (~/.codex/sessions/YYYY/MM/DD/rollout-<time>-<id>.jsonl) */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.codex_source = exports.createCodexSource = void 0;
|
|
8
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
11
|
+
const jsonl_1 = require("../jsonl");
|
|
12
|
+
const json_1 = require("../../../core/json");
|
|
13
|
+
const codex_dir = process.env.CODEX_HOME || node_path_1.default.join(node_os_1.default.homedir(), '.codex');
|
|
14
|
+
/* -------------------------------------------------------------------------- */
|
|
15
|
+
/* Listing */
|
|
16
|
+
/* -------------------------------------------------------------------------- */
|
|
17
|
+
function walkJsonl(dir, files = []) {
|
|
18
|
+
if (!node_fs_1.default.existsSync(dir))
|
|
19
|
+
return files;
|
|
20
|
+
for (const e of node_fs_1.default.readdirSync(dir, { withFileTypes: true })) {
|
|
21
|
+
const p = node_path_1.default.join(dir, e.name);
|
|
22
|
+
if (e.isDirectory())
|
|
23
|
+
walkJsonl(p, files);
|
|
24
|
+
else if (e.isFile() && e.name.endsWith('.jsonl'))
|
|
25
|
+
files.push(p);
|
|
26
|
+
}
|
|
27
|
+
return files;
|
|
28
|
+
}
|
|
29
|
+
/** session_meta is the first record of every session file */
|
|
30
|
+
async function readSessionMeta(file) {
|
|
31
|
+
for await (const rec of (0, jsonl_1.readJsonl)(file)) {
|
|
32
|
+
if (rec.type !== 'session_meta')
|
|
33
|
+
return undefined;
|
|
34
|
+
const p = (0, json_1.asRecord)(rec.payload);
|
|
35
|
+
if (!p.id)
|
|
36
|
+
return undefined;
|
|
37
|
+
return { id: String(p.id), cwd: String(p.cwd ?? ''), parent: (0, json_1.asString)(p.parent_thread_id) };
|
|
38
|
+
}
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
/** Thread names from session_index.jsonl, the last entry of an id wins */
|
|
42
|
+
async function readThreadNames(root) {
|
|
43
|
+
const names = new Map();
|
|
44
|
+
const file = node_path_1.default.join(root, 'session_index.jsonl');
|
|
45
|
+
if (!node_fs_1.default.existsSync(file))
|
|
46
|
+
return names;
|
|
47
|
+
for await (const rec of (0, jsonl_1.readJsonl)(file)) {
|
|
48
|
+
if (typeof rec.id === 'string' && typeof rec.thread_name === 'string')
|
|
49
|
+
names.set(rec.id, rec.thread_name);
|
|
50
|
+
}
|
|
51
|
+
return names;
|
|
52
|
+
}
|
|
53
|
+
async function listProjects(root) {
|
|
54
|
+
const names = await readThreadNames(root);
|
|
55
|
+
const sessions_dirs = ['sessions', 'archived_sessions'].map((dir) => node_path_1.default.join(root, dir));
|
|
56
|
+
const metas = [];
|
|
57
|
+
for (const file of sessions_dirs.flatMap((d) => walkJsonl(d))) {
|
|
58
|
+
const meta = await readSessionMeta(file);
|
|
59
|
+
if (!meta)
|
|
60
|
+
continue;
|
|
61
|
+
const mtime = node_fs_1.default.statSync(file).mtimeMs;
|
|
62
|
+
const source = { sessionId: meta.id, file, mtime, subFiles: [], title: names.get(meta.id) };
|
|
63
|
+
metas.push({ ...meta, source });
|
|
64
|
+
}
|
|
65
|
+
/* subagent sessions are separate files that point to their parent thread */
|
|
66
|
+
const byId = new Map(metas.map((m) => [m.id, m]));
|
|
67
|
+
const projects = new Map();
|
|
68
|
+
for (const m of metas.sort((a, b) => a.source.mtime - b.source.mtime)) {
|
|
69
|
+
const parent = m.parent ? byId.get(m.parent) : undefined;
|
|
70
|
+
if (parent) {
|
|
71
|
+
parent.source.subFiles.push(m.source.file);
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
const folder = (0, jsonl_1.folderFromCwd)(m.cwd);
|
|
75
|
+
if (!projects.has(folder))
|
|
76
|
+
projects.set(folder, { folder, cwd: m.cwd, sessions: [] });
|
|
77
|
+
projects.get(folder)?.sessions.push(m.source);
|
|
78
|
+
}
|
|
79
|
+
return [...projects.values()];
|
|
80
|
+
}
|
|
81
|
+
/* -------------------------------------------------------------------------- */
|
|
82
|
+
/* Records */
|
|
83
|
+
/* -------------------------------------------------------------------------- */
|
|
84
|
+
/** Context Codex injects into user messages: <environment_context>, AGENTS.md, ... */
|
|
85
|
+
function isInjected(text) {
|
|
86
|
+
const t = text.trimStart();
|
|
87
|
+
return /^<[a-z_]+>/.test(t) || t.startsWith('# AGENTS.md');
|
|
88
|
+
}
|
|
89
|
+
function userText(content) {
|
|
90
|
+
return content
|
|
91
|
+
.map((value) => {
|
|
92
|
+
const c = (0, json_1.asRecord)(value);
|
|
93
|
+
if (c?.type === 'input_text' && typeof c.text === 'string' && !isInjected(c.text))
|
|
94
|
+
return c.text;
|
|
95
|
+
if (c?.type === 'input_image')
|
|
96
|
+
return '_[image]_';
|
|
97
|
+
return '';
|
|
98
|
+
})
|
|
99
|
+
.filter((t) => t.length > 0)
|
|
100
|
+
.join('\n\n');
|
|
101
|
+
}
|
|
102
|
+
function prettyArguments(args) {
|
|
103
|
+
if (typeof args !== 'string')
|
|
104
|
+
return JSON.stringify(args ?? {}, null, 2);
|
|
105
|
+
try {
|
|
106
|
+
return JSON.stringify(JSON.parse(args), null, 2);
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return args;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function payloadParts(p) {
|
|
113
|
+
const content = Array.isArray(p.content) ? p.content.map(json_1.asRecord) : [];
|
|
114
|
+
switch (p.type) {
|
|
115
|
+
case 'message': {
|
|
116
|
+
if (p.role === 'user') {
|
|
117
|
+
const text = userText(content);
|
|
118
|
+
return text ? [{ kind: 'user', text }] : [];
|
|
119
|
+
}
|
|
120
|
+
if (p.role !== 'assistant')
|
|
121
|
+
return []; // developer: instructions injected by Codex
|
|
122
|
+
const text = content
|
|
123
|
+
.filter((c) => c?.type === 'output_text' && typeof c.text === 'string')
|
|
124
|
+
.map((c) => c.text)
|
|
125
|
+
.join('\n\n');
|
|
126
|
+
return text ? [{ kind: 'assistant', text, group: (0, json_1.asString)(p.id) }] : [];
|
|
127
|
+
}
|
|
128
|
+
case 'reasoning': {
|
|
129
|
+
const summary = Array.isArray(p.summary) ? p.summary.map(json_1.asRecord) : [];
|
|
130
|
+
const text = summary
|
|
131
|
+
.map((s) => (typeof s?.text === 'string' ? s.text : ''))
|
|
132
|
+
.filter((t) => t.length > 0)
|
|
133
|
+
.join('\n\n');
|
|
134
|
+
return text ? [{ kind: 'thinking', text, group: (0, json_1.asString)(p.id) }] : [];
|
|
135
|
+
}
|
|
136
|
+
case 'function_call':
|
|
137
|
+
return [
|
|
138
|
+
{ kind: 'tool_call', text: prettyArguments(p.arguments), toolName: (0, json_1.asString)(p.name), toolId: (0, json_1.asString)(p.call_id), lang: 'json' },
|
|
139
|
+
];
|
|
140
|
+
case 'custom_tool_call':
|
|
141
|
+
return [{ kind: 'tool_call', text: String(p.input ?? ''), toolName: (0, json_1.asString)(p.name), toolId: (0, json_1.asString)(p.call_id) }];
|
|
142
|
+
case 'function_call_output':
|
|
143
|
+
case 'custom_tool_call_output':
|
|
144
|
+
return [{ kind: 'tool_result', text: (0, jsonl_1.blocksText)(p.output), toolId: (0, json_1.asString)(p.call_id) }];
|
|
145
|
+
default:
|
|
146
|
+
return [];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
async function* readEntries(file, isSubFile) {
|
|
150
|
+
for await (const rec of (0, jsonl_1.readJsonl)(file)) {
|
|
151
|
+
const p = (0, json_1.asRecord)(rec.payload);
|
|
152
|
+
const e = { timestamp: (0, json_1.asString)(rec.timestamp), sidechain: isSubFile, parts: [] };
|
|
153
|
+
if (rec.type === 'session_meta') {
|
|
154
|
+
e.cwd = (0, json_1.asString)(p.cwd);
|
|
155
|
+
e.gitBranch = (0, json_1.asString)((0, json_1.asRecord)(p.git).branch);
|
|
156
|
+
}
|
|
157
|
+
else if (rec.type === 'turn_context') {
|
|
158
|
+
e.cwd = (0, json_1.asString)(p.cwd);
|
|
159
|
+
}
|
|
160
|
+
else if (rec.type === 'response_item') {
|
|
161
|
+
e.parts = payloadParts(p);
|
|
162
|
+
}
|
|
163
|
+
yield e;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function createCodexSource(root) {
|
|
167
|
+
return { name: 'codex', root, listProjects: () => listProjects(root), readEntries };
|
|
168
|
+
}
|
|
169
|
+
exports.createCodexSource = createCodexSource;
|
|
170
|
+
exports.codex_source = createCodexSource(codex_dir);
|
|
171
|
+
//# sourceMappingURL=codex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../../../src/features/transcripts/sources/codex.ts"],"names":[],"mappings":";AAAA,8FAA8F;;;;;;AAE9F,sDAAyB;AACzB,sDAAyB;AACzB,0DAA6B;AAC7B,oCAAgE;AAEhE,6CAAwD;AAExD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,mBAAI,CAAC,IAAI,CAAC,iBAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AAG9E,gFAAgF;AAChF,gFAAgF;AAChF,gFAAgF;AAChF,SAAS,SAAS,CAAC,GAAW,EAAE,QAAkB,EAAE;IACnD,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACtC,KAAK,MAAM,CAAC,IAAI,iBAAE,CAAC,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,EAAE;QAC7D,MAAM,CAAC,GAAG,mBAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,CAAC,CAAC,WAAW,EAAE;YAAE,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;aACpC,IAAI,CAAC,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KAChE;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,6DAA6D;AAC7D,KAAK,UAAU,eAAe,CAAC,IAAY;IAC1C,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,IAAA,iBAAS,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c,EAAE;YACvC,CAAC,CAAC,GAAG,GAAG,IAAA,eAAQ,EAAC,CAAC,CAAC,GAAG,CAAC,CAAC;SACxB;aAAM,IAAI,GAAG,CAAC,IAAI,KAAK,eAAe,EAAE;YACxC,CAAC,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,CAAC;SAC1B;QACD,MAAM,CAAC,CAAC;KACR;AACF,CAAC;AAED,SAAgB,iBAAiB,CAAC,IAAY;IAC7C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,WAAW,EAAE,CAAC;AACrF,CAAC;AAFD,8CAEC;AAEY,QAAA,YAAY,GAAG,iBAAiB,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/features/transcripts/types.ts"],"names":[],"mappings":";;;AAoEa,QAAA,WAAW,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAU,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const options_1 = require("../../cli/options");
|
|
4
|
+
const project_type_1 = require("../../core/project-type");
|
|
5
|
+
const update_1 = require("./update");
|
|
6
|
+
const command = {
|
|
7
|
+
command: 'up [target..]',
|
|
8
|
+
describe: 'Update packages while keeping workspace dependencies',
|
|
9
|
+
builder: (cli) => cli.options(options_1.projectOptions)
|
|
10
|
+
.positional('target', { type: 'string', array: true, describe: 'Packages to update; omit for all' })
|
|
11
|
+
.option('dedupe', { type: 'boolean', describe: 'Deduplicate Yarn dependencies after updating' })
|
|
12
|
+
.option('prod', { type: 'boolean', describe: 'Install locked production Composer dependencies' }),
|
|
13
|
+
handler: async (args) => { await (0, update_1.updateProject)((0, project_type_1.loadProjectType)(args), args); },
|
|
14
|
+
};
|
|
15
|
+
exports.default = command;
|
|
16
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../src/features/update/command.ts"],"names":[],"mappings":";;AACA,+CAAmD;AACnD,0DAA0E;AAC1E,qCAAyC;AAGzC,MAAM,OAAO,GAAqC;IACjD,OAAO,EAAE,eAAe;IACxB,QAAQ,EAAE,sDAAsD;IAChE,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,wBAAc,CAAC;SAC3C,UAAU,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,kCAAkC,EAAE,CAAC;SACnG,MAAM,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,8CAA8C,EAAE,CAAC;SAC/F,MAAM,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,iDAAiD,EAAE,CAAC;IAClG,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,GAAG,MAAM,IAAA,sBAAa,EAAC,IAAA,8BAAe,EAAC,IAAI,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;CAC9E,CAAC;AACF,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updateComposer = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const files_1 = require("../../core/files");
|
|
9
|
+
const json_1 = require("../../core/json");
|
|
10
|
+
const process_1 = require("../../core/process");
|
|
11
|
+
async function updateComposer(options, run = process_1.runCommand) {
|
|
12
|
+
const cwd = node_path_1.default.resolve(options.path ?? process.cwd());
|
|
13
|
+
const execution = { cwd, quiet: options.quiet };
|
|
14
|
+
if (options.prod) {
|
|
15
|
+
await run('composer', ['install', '--no-ansi', '--no-dev', '--no-interaction', '--no-plugins', '--no-progress', '--no-scripts', '--optimize-autoloader'], execution);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
for (const file of ['composer.lock', 'vendor'])
|
|
19
|
+
(0, files_1.removeIfExists)(node_path_1.default.join(cwd, file));
|
|
20
|
+
await run('composer', ['clearcache'], execution);
|
|
21
|
+
await run('composer', ['install'], execution);
|
|
22
|
+
const result = await run('composer', ['show', '--no-dev', '-f', 'json'], { ...execution, quiet: true });
|
|
23
|
+
const packages = (0, json_1.asRecord)(JSON.parse(result.stdout)).installed;
|
|
24
|
+
if (!Array.isArray(packages))
|
|
25
|
+
throw new Error('Invalid Composer package list.');
|
|
26
|
+
for (const item of packages) {
|
|
27
|
+
const name = (0, json_1.asRecord)(item).name;
|
|
28
|
+
if (typeof name !== 'string')
|
|
29
|
+
throw new Error('Invalid Composer package name.');
|
|
30
|
+
await run('composer', ['require', name], execution);
|
|
31
|
+
}
|
|
32
|
+
await run('composer', ['update'], execution);
|
|
33
|
+
}
|
|
34
|
+
exports.updateComposer = updateComposer;
|
|
35
|
+
//# sourceMappingURL=composer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composer.js","sourceRoot":"","sources":["../../../src/features/update/composer.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,4CAAkD;AAClD,0CAA2C;AAC3C,gDAA+D;AAGxD,KAAK,UAAU,cAAc,CAAC,OAAsB,EAAE,MAAqB,oBAAU;IAC3F,MAAM,GAAG,GAAG,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACxD,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,KA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C,EAAE,SAAS,CAAC,CAAC;KACpD;IACD,MAAM,GAAG,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,CAAC;AAC9C,CAAC;AAnBD,wCAmBC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Acceptable options:
|
|
4
|
+
- Keep workspace dependencies.
|
|
5
|
+
- Use latest dependencies.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
function findAcceptableIndex(options) {
|
|
9
|
+
let depIndex = options.findIndex((s) => filterWorkspace(s));
|
|
10
|
+
if (depIndex < 0)
|
|
11
|
+
depIndex = options.findIndex((s) => filterLatest(s));
|
|
12
|
+
return depIndex;
|
|
13
|
+
}
|
|
14
|
+
exports.default = findAcceptableIndex;
|
|
15
|
+
const KEEP_WORKSPACE_DEPENDENCY = new RegExp('attach.*workspace', 'i');
|
|
16
|
+
function filterWorkspace(option) {
|
|
17
|
+
return KEEP_WORKSPACE_DEPENDENCY.test(option);
|
|
18
|
+
}
|
|
19
|
+
const USE_RESOLVED_FROM_LATEST = new RegExp('use.*latest', 'i');
|
|
20
|
+
function filterLatest(option) {
|
|
21
|
+
return USE_RESOLVED_FROM_LATEST.test(option);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=filter-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-options.js","sourceRoot":"","sources":["../../../src/features/update/filter-options.ts"],"names":[],"mappings":";AAAA;;;;EAIE;;AAEF,SAAwB,mBAAmB,CAAC,OAAiB;IAC5D,IAAI,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5D,IAAI,QAAQ,GAAG,CAAC;QAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACvE,OAAO,QAAQ,CAAC;AACjB,CAAC;AAJD,sCAIC;AAED,MAAM,yBAAyB,GAAG,IAAI,MAAM,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;AACvE,SAAS,eAAe,CAAC,MAAc;IACtC,OAAO,yBAAyB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC;AAED,MAAM,wBAAwB,GAAG,IAAI,MAAM,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AAChE,SAAS,YAAY,CAAC,MAAc;IACnC,OAAO,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updateProject = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const process_1 = require("../../core/process");
|
|
9
|
+
const logger_1 = require("../../core/logger");
|
|
10
|
+
const composer_1 = require("./composer");
|
|
11
|
+
const yarn_1 = require("./yarn");
|
|
12
|
+
async function updateProject(type, options, run = process_1.runCommand) {
|
|
13
|
+
if (type === 'php')
|
|
14
|
+
await (0, composer_1.updateComposer)(options, run);
|
|
15
|
+
else if (type === 'yarn')
|
|
16
|
+
await (0, yarn_1.updateYarn)(options, run);
|
|
17
|
+
else if (type === 'python') {
|
|
18
|
+
const execution = { cwd: node_path_1.default.resolve(options.path ?? process.cwd()), quiet: options.quiet };
|
|
19
|
+
await run('python', ['-m', 'pip', 'cache', 'purge'], execution);
|
|
20
|
+
await run('python', ['-m', 'pip', 'install', '-r', 'requirements.txt'], execution);
|
|
21
|
+
}
|
|
22
|
+
else
|
|
23
|
+
throw new Error(`Updating is not supported for ${type} projects.`);
|
|
24
|
+
if (!options.quiet)
|
|
25
|
+
(0, logger_1.showMessage)('Update done', 'text');
|
|
26
|
+
}
|
|
27
|
+
exports.updateProject = updateProject;
|
|
28
|
+
//# sourceMappingURL=update.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update.js","sourceRoot":"","sources":["../../../src/features/update/update.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,gDAA+D;AAE/D,8CAAgD;AAEhD,yCAA4C;AAC5C,iCAAoC;AAE7B,KAAK,UAAU,aAAa,CAAC,IAAiB,EAAE,OAAsB,EAAE,MAAqB,oBAAU;IAC7G,IAAI,IAAI,KAAK,KAAK;QAAE,MAAM,IAAA,yBAAc,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;SAClD,IAAI,IAAI,KAAK,MAAM;QAAE,MAAM,IAAA,iBAAU,EAAC,OAAO,EAAE,GAAG,CAAC,CAAC;SACpD,IAAI,IAAI,KAAK,QAAQ,EAAE;QAC3B,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,mBAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;QAC7F,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,SAAS,CAAC,CAAC;QAChE,MAAM,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,CAAC,EAAE,SAAS,CAAC,CAAC;KACnF;;QAAM,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,YAAY,CAAC,CAAC;IAC1E,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,IAAA,oBAAW,EAAC,aAAa,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC;AATD,sCASC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.updateYarn = void 0;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const process_1 = require("../../core/process");
|
|
9
|
+
const filter_options_1 = __importDefault(require("./filter-options"));
|
|
10
|
+
async function updateYarn(options, run = process_1.runCommand) {
|
|
11
|
+
const cwd = node_path_1.default.resolve(options.path ?? process.cwd());
|
|
12
|
+
const targets = options.target?.length ? options.target : [undefined];
|
|
13
|
+
for (const target of targets) {
|
|
14
|
+
await run('yarn', ['up', '--interactive', ...(target ? [target] : [])], {
|
|
15
|
+
cwd,
|
|
16
|
+
quiet: options.quiet,
|
|
17
|
+
onStdout(chunk, stdin) {
|
|
18
|
+
const lines = chunk.split('\n');
|
|
19
|
+
const accepted = (0, filter_options_1.default)(lines);
|
|
20
|
+
const selected = lines.findIndex((line) => line.trim().includes('>'));
|
|
21
|
+
if (accepted > 0 && selected >= 0)
|
|
22
|
+
stdin.write(accepted === selected ? '\n' : '\u001b[B');
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
if (options.dedupe)
|
|
27
|
+
await run('yarn', ['dedupe'], { cwd, quiet: options.quiet });
|
|
28
|
+
}
|
|
29
|
+
exports.updateYarn = updateYarn;
|
|
30
|
+
//# sourceMappingURL=yarn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yarn.js","sourceRoot":"","sources":["../../../src/features/update/yarn.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAC7B,gDAA+D;AAC/D,sEAAmD;AAG5C,KAAK,UAAU,UAAU,CAAC,OAAsB,EAAE,MAAqB,oBAAU;IACvF,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