@crewx/dreaming 0.1.0-rc.5 → 0.1.0-rc.50
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/SKILL.md +47 -2
- package/dist/cli.d.ts +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +217 -26
- package/dist/cli.js.map +1 -1
- package/dist/src/analyzer.d.ts +8 -1
- package/dist/src/analyzer.d.ts.map +1 -1
- package/dist/src/analyzer.js +167 -8
- package/dist/src/analyzer.js.map +1 -1
- package/dist/src/renderer.d.ts +12 -2
- package/dist/src/renderer.d.ts.map +1 -1
- package/dist/src/renderer.js +171 -29
- package/dist/src/renderer.js.map +1 -1
- package/dist/src/scrub.d.ts +4 -0
- package/dist/src/scrub.d.ts.map +1 -0
- package/dist/src/scrub.js +58 -0
- package/dist/src/scrub.js.map +1 -0
- package/dist/src/types.d.ts +44 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +3 -3
package/SKILL.md
CHANGED
|
@@ -20,6 +20,7 @@ memory(기억 저장/검색), doc(설계서 탐색), search(코드 검색)와
|
|
|
20
20
|
|--------|------|---------|
|
|
21
21
|
| `crewx dreaming --task=tsk_xxx` | 돋보기 | 태스크 1건을 깊게 — 행동 타임라인, 삽질 패턴, 효율 패턴, 스킬 사용 현황 |
|
|
22
22
|
| `crewx dreaming --thread=thd_xxx --recent=N` | 지도 | 대화 내 최근 N개 태스크 목록 + 각 종료상태 |
|
|
23
|
+
| `crewx dreaming --thread=thd_xxx --agent=self --continue` | 이어보기 | 내 직전 작업 1건 상세 + 그 이전 N건 규칙 기반 요약 |
|
|
23
24
|
|
|
24
25
|
## 언제 호출할까 (에이전트 판단 기준)
|
|
25
26
|
|
|
@@ -87,11 +88,55 @@ Agent: core_dev (acp/claude) | Status: success | Duration: 312s | Tools: 47 call
|
|
|
87
88
|
드릴다운: crewx dreaming --task=<id>
|
|
88
89
|
```
|
|
89
90
|
|
|
91
|
+
## 출력 예시 — --continue 모드 (이전 내 작업 이어보기)
|
|
92
|
+
|
|
93
|
+
같은 thread 안에서 **현재 agent 자신의** 이전 작업만 골라, 최신 1건은 자세히 + 그 이전은 규칙 기반 한 줄 요약으로 보여준다. 요약은 LLM이 아니라 tool count / status / duration / files 기반이다.
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
━━━ 이전 내 작업 이어보기 ━━━
|
|
97
|
+
Thread: thd_xyz789 | Agent: core_lead
|
|
98
|
+
|
|
99
|
+
[직전 작업]
|
|
100
|
+
|
|
101
|
+
━━━ Dreaming: task tsk_123 ━━━
|
|
102
|
+
... 자세한 활동 기록 (타임라인 캡 30, --full로 해제) ...
|
|
103
|
+
|
|
104
|
+
[이전 작업 요약]
|
|
105
|
+
- tsk_122 | ✅ success | 120s | Bash 3회, Read 4회, Edit 0회
|
|
106
|
+
- tsk_121 | ❌ failed | 45s | Bash 2회 | ⚠️ 삽질
|
|
107
|
+
|
|
108
|
+
━━━ 다음 액션 ━━━
|
|
109
|
+
전체 활동 기록:
|
|
110
|
+
crewx dreaming --task=tsk_122 --full
|
|
111
|
+
상세 작업 기록 JSON:
|
|
112
|
+
crewx dreaming --task=tsk_122 --json
|
|
113
|
+
이 대화 작업 목록:
|
|
114
|
+
crewx dreaming --thread=thd_xyz789 --agent=core_lead
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
# 현재 agent 자신의 이전 작업 이어보기
|
|
119
|
+
crewx dreaming --thread=thd_xyz789 --agent=self --continue
|
|
120
|
+
|
|
121
|
+
# 명시 agent + 최근 3건 (최신 1 상세 + 이전 2 요약)
|
|
122
|
+
crewx dreaming --thread=thd_xyz789 --agent=core_lead --continue --recent=3
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
> `--agent=self` 는 `CREWX_AGENT_ID` 환경변수로 현재 agent를 해석한다. 환경변수가 없으면 명시 agent id를 써야 한다.
|
|
126
|
+
|
|
90
127
|
## Options
|
|
91
128
|
|
|
92
129
|
| 옵션 | 기본값 | 설명 |
|
|
93
130
|
|------|--------|------|
|
|
94
131
|
| `--task=ID` | — | 태스크 ID (tsk_xxx) |
|
|
95
132
|
| `--thread=ID` | — | 스레드 ID (thd_xxx) |
|
|
96
|
-
| `--
|
|
97
|
-
| `--
|
|
133
|
+
| `--agent=ID` | — | thread 안에서 특정 agent만 (`self` → 현재 agent) |
|
|
134
|
+
| `--continue` | false | 이전 내 작업 이어보기 (최신 1 상세 + 이전 N 규칙 요약) |
|
|
135
|
+
| `--recent=N` | 목록 5 / continue 3 | 최근 N건 |
|
|
136
|
+
| `--full` | false | 타임라인 캡 해제 + JSON에 raw 필드 포함 |
|
|
137
|
+
| `--json` | false | 순수 JSON 출력 (CAL footer 없음) |
|
|
138
|
+
|
|
139
|
+
## CAL "다음 액션"
|
|
140
|
+
|
|
141
|
+
human 출력 하단에는 다음 행동을 안내하는 CAL footer가 붙는다 (`--full`, `--json`, thread 드릴다운).
|
|
142
|
+
**`--json` 출력에는 footer가 붙지 않으며 단일 JSON으로 파싱 가능하다.** `--full` 없이는 JSON에서 원본 입력/결과 필드를 제외한다.
|
package/dist/cli.d.ts
CHANGED
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AA2BA,eAAO,MAAM,2BAA2B,OAAO,CAAC;AA8IhD,wBAAsB,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAyK9D"}
|
package/dist/cli.js
CHANGED
|
@@ -1,10 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
20
|
+
var ownKeys = function(o) {
|
|
21
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
22
|
+
var ar = [];
|
|
23
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
24
|
+
return ar;
|
|
25
|
+
};
|
|
26
|
+
return ownKeys(o);
|
|
27
|
+
};
|
|
28
|
+
return function (mod) {
|
|
29
|
+
if (mod && mod.__esModule) return mod;
|
|
30
|
+
var result = {};
|
|
31
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
32
|
+
__setModuleDefault(result, mod);
|
|
33
|
+
return result;
|
|
34
|
+
};
|
|
35
|
+
})();
|
|
3
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.DEFAULT_ACTIVITY_LOG_BUDGET = void 0;
|
|
4
38
|
exports.main = main;
|
|
5
39
|
const sdk_1 = require("@crewx/sdk");
|
|
40
|
+
const fs = __importStar(require("fs"));
|
|
41
|
+
const path = __importStar(require("path"));
|
|
6
42
|
const analyzer_js_1 = require("./src/analyzer.js");
|
|
43
|
+
const scrub_js_1 = require("./src/scrub.js");
|
|
7
44
|
const renderer_js_1 = require("./src/renderer.js");
|
|
45
|
+
exports.DEFAULT_ACTIVITY_LOG_BUDGET = 8000;
|
|
46
|
+
const DEFAULT_TASK_TIMELINE = 60;
|
|
47
|
+
const CONTINUE_LATEST_TIMELINE = 30;
|
|
8
48
|
function parseFlags(argv) {
|
|
9
49
|
const flags = {
|
|
10
50
|
task: null,
|
|
@@ -14,12 +54,22 @@ function parseFlags(argv) {
|
|
|
14
54
|
recent: null,
|
|
15
55
|
json: false,
|
|
16
56
|
all: false,
|
|
57
|
+
continue: false,
|
|
58
|
+
full: false,
|
|
59
|
+
lookback: 3,
|
|
60
|
+
activityLog: false,
|
|
17
61
|
};
|
|
18
62
|
for (const a of argv) {
|
|
19
63
|
if (a === '--json')
|
|
20
64
|
flags.json = true;
|
|
21
65
|
else if (a === '--all')
|
|
22
66
|
flags.all = true;
|
|
67
|
+
else if (a === '--full')
|
|
68
|
+
flags.full = true;
|
|
69
|
+
else if (a === '--continue')
|
|
70
|
+
flags.continue = true;
|
|
71
|
+
else if (a === '--activity-log')
|
|
72
|
+
flags.activityLog = true;
|
|
23
73
|
else if (a.startsWith('--task='))
|
|
24
74
|
flags.task = a.slice('--task='.length);
|
|
25
75
|
else if (a.startsWith('--thread='))
|
|
@@ -30,6 +80,8 @@ function parseFlags(argv) {
|
|
|
30
80
|
flags.days = parseInt(a.slice('--days='.length), 10);
|
|
31
81
|
else if (a.startsWith('--recent='))
|
|
32
82
|
flags.recent = parseInt(a.slice('--recent='.length), 10);
|
|
83
|
+
else if (a.startsWith('--lookback='))
|
|
84
|
+
flags.lookback = parseInt(a.slice('--lookback='.length), 10);
|
|
33
85
|
else if (a === '--help' || a === '-h') {
|
|
34
86
|
printUsage();
|
|
35
87
|
process.exit(0);
|
|
@@ -42,41 +94,95 @@ function parseFlags(argv) {
|
|
|
42
94
|
return flags;
|
|
43
95
|
}
|
|
44
96
|
function printUsage() {
|
|
45
|
-
console.log(`crewx dreaming —
|
|
97
|
+
console.log(`crewx dreaming — Selective reflection skill
|
|
46
98
|
|
|
47
|
-
|
|
48
|
-
memory/doc/search
|
|
99
|
+
A first-class reflection tool agents call before/after work or during retries to recover context.
|
|
100
|
+
Use it proactively alongside memory/doc/search when the situation calls for it.
|
|
49
101
|
|
|
50
102
|
Usage:
|
|
51
|
-
crewx dreaming --task=TASK_ID
|
|
52
|
-
crewx dreaming --thread=THREAD_ID [--recent=N]
|
|
103
|
+
crewx dreaming --task=TASK_ID [--full] [--json]
|
|
104
|
+
crewx dreaming --thread=THREAD_ID [--agent=AGENT_ID] [--recent=N]
|
|
105
|
+
crewx dreaming --thread=THREAD_ID --agent=AGENT_ID --continue [--recent=N] [--full] [--json]
|
|
106
|
+
crewx dreaming --thread=THREAD_ID --agent=AGENT_ID --activity-log [--lookback=N] [--json]
|
|
53
107
|
|
|
54
108
|
Options:
|
|
55
|
-
--task=ID
|
|
56
|
-
--thread=ID
|
|
57
|
-
--
|
|
58
|
-
--
|
|
59
|
-
--
|
|
109
|
+
--task=ID Deep reflection for one task (timeline + skill usage + struggle/efficiency summary)
|
|
110
|
+
--thread=ID List the last N tasks in a conversation with each end status
|
|
111
|
+
--agent=ID Restrict thread view to one agent (--agent=self means current agent)
|
|
112
|
+
--continue Continue previous work: latest task details plus rule-based summary of prior tasks
|
|
113
|
+
--activity-log Output precomputed <activity_log> XML of read-only results from previous N tasks
|
|
114
|
+
--lookback=N N-back depth for --activity-log (default: 3, 0 = disabled, max recommended: 5)
|
|
115
|
+
--recent=N Last N items (list default: 5 / continue default: 3)
|
|
116
|
+
--full Show the full timeline and include raw fields in JSON
|
|
117
|
+
--json Pure JSON output without a CAL footer
|
|
118
|
+
--help, -h Show help
|
|
60
119
|
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
120
|
+
When to call:
|
|
121
|
+
- Before starting: check whether there is an interrupted task
|
|
122
|
+
- Before retrying after failure: recover where the previous attempt stopped
|
|
123
|
+
- To understand conversation context: use --thread to list tasks in this conversation
|
|
124
|
+
- Continue previous work: --thread --agent --continue
|
|
125
|
+
- SDK prompt assembly: --activity-log to inject precomputed read-only results
|
|
66
126
|
|
|
67
127
|
Examples:
|
|
68
|
-
crewx dreaming --task=tsk_abc123
|
|
128
|
+
crewx dreaming --task=tsk_abc123 --full
|
|
69
129
|
crewx dreaming --thread=thd_xyz789 --recent=5
|
|
70
|
-
crewx dreaming --thread=thd_xyz789 --
|
|
130
|
+
crewx dreaming --thread=thd_xyz789 --agent=core_lead --continue
|
|
131
|
+
crewx dreaming --thread=thd_xyz789 --agent=core_lead --activity-log --lookback=2
|
|
71
132
|
`);
|
|
72
133
|
}
|
|
134
|
+
function showDetailedUsage() {
|
|
135
|
+
const skillMd = path.join(__dirname, '..', 'SKILL.md');
|
|
136
|
+
if (fs.existsSync(skillMd)) {
|
|
137
|
+
process.stdout.write(fs.readFileSync(skillMd, 'utf-8'));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
printUsage();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function resolveAgent(agent) {
|
|
144
|
+
if (agent !== 'self')
|
|
145
|
+
return agent;
|
|
146
|
+
const envAgent = process.env.CREWX_AGENT_ID;
|
|
147
|
+
if (!envAgent) {
|
|
148
|
+
console.error('Error: --agent=self requires CREWX_AGENT_ID in the environment.\n' +
|
|
149
|
+
'Pass an explicit agent id instead, e.g. --agent=core_lead.');
|
|
150
|
+
process.exit(1);
|
|
151
|
+
}
|
|
152
|
+
return envAgent;
|
|
153
|
+
}
|
|
154
|
+
function jsonSafeAnalysis(a, full) {
|
|
155
|
+
if (full)
|
|
156
|
+
return a;
|
|
157
|
+
return {
|
|
158
|
+
...a,
|
|
159
|
+
timeline: a.timeline.map((e) => {
|
|
160
|
+
const { input: _input, resultPreview: _resultPreview, ...rest } = e;
|
|
161
|
+
return rest;
|
|
162
|
+
}),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
function writeJson(obj) {
|
|
166
|
+
process.stdout.write(JSON.stringify((0, scrub_js_1.scrubSecrets)(obj), null, 2) + '\n');
|
|
167
|
+
}
|
|
168
|
+
function topLevelByThread(taskRepo, threadId) {
|
|
169
|
+
return taskRepo
|
|
170
|
+
.findTasksByThread(threadId)
|
|
171
|
+
.filter((t) => !t.parent_task_id)
|
|
172
|
+
.sort((a, b) => (b.started_at > a.started_at ? 1 : -1));
|
|
173
|
+
}
|
|
73
174
|
async function main(inputArgs) {
|
|
74
175
|
const args = inputArgs ?? process.argv.slice(2);
|
|
176
|
+
if (args[0] === 'usage') {
|
|
177
|
+
showDetailedUsage();
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
75
180
|
if (!args.length || args[0] === '--help' || args[0] === '-h') {
|
|
76
181
|
printUsage();
|
|
77
182
|
return;
|
|
78
183
|
}
|
|
79
184
|
const flags = parseFlags(args);
|
|
185
|
+
const agent = resolveAgent(flags.agent);
|
|
80
186
|
if (!flags.task && !flags.thread) {
|
|
81
187
|
console.error('Error: --task=<id> or --thread=<id> is required.\nRun crewx dreaming --help for usage.');
|
|
82
188
|
process.exit(1);
|
|
@@ -92,19 +198,93 @@ async function main(inputArgs) {
|
|
|
92
198
|
const spans = spanRepo.findByTaskId(flags.task);
|
|
93
199
|
const result = (0, analyzer_js_1.analyzeTask)(row, spans);
|
|
94
200
|
if (flags.json) {
|
|
95
|
-
|
|
201
|
+
writeJson(jsonSafeAnalysis(result, flags.full));
|
|
96
202
|
return;
|
|
97
203
|
}
|
|
98
|
-
|
|
204
|
+
const detail = (0, renderer_js_1.renderTaskFull)(result, {
|
|
205
|
+
maxTimeline: flags.full ? null : DEFAULT_TASK_TIMELINE,
|
|
206
|
+
});
|
|
207
|
+
const actions = [];
|
|
208
|
+
if (!flags.full) {
|
|
209
|
+
actions.push({ label: 'Full activity log', cmd: `crewx dreaming --task=${result.taskId} --full` });
|
|
210
|
+
}
|
|
211
|
+
actions.push({ label: 'Detailed task log JSON', cmd: `crewx dreaming --task=${result.taskId} --json` });
|
|
212
|
+
console.log(detail + '\n' + (0, renderer_js_1.buildCalFooter)(actions));
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (flags.thread && flags.activityLog) {
|
|
216
|
+
if (!agent) {
|
|
217
|
+
console.error('Error: --activity-log requires --agent=<id> (or --agent=self).');
|
|
218
|
+
process.exit(1);
|
|
219
|
+
}
|
|
220
|
+
const lookback = flags.lookback;
|
|
221
|
+
if (lookback === 0) {
|
|
222
|
+
if (flags.json) {
|
|
223
|
+
writeJson({ mode: 'activity-log', lookback: 0, entries: [], truncated: false, xml: '' });
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
process.stdout.write('');
|
|
227
|
+
}
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
const rows = topLevelByThread(taskRepo, flags.thread)
|
|
231
|
+
.filter((t) => t.agent_id === agent)
|
|
232
|
+
.slice(0, Math.min(lookback, 5));
|
|
233
|
+
const analyses = rows.map((t) => (0, analyzer_js_1.analyzeTask)(t, spanRepo.findByTaskId(t.id)));
|
|
234
|
+
const log = (0, analyzer_js_1.buildActivityLog)(analyses, flags.thread, agent, lookback, exports.DEFAULT_ACTIVITY_LOG_BUDGET);
|
|
235
|
+
if (flags.json) {
|
|
236
|
+
writeJson({ mode: 'activity-log', ...log, xml: (0, renderer_js_1.renderActivityLogXml)(log) });
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
process.stdout.write((0, renderer_js_1.renderActivityLogXml)(log) + '\n');
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
if (flags.thread && flags.continue) {
|
|
243
|
+
if (!agent) {
|
|
244
|
+
console.error('Error: --continue requires --agent=<id> (or --agent=self).');
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
const recent = flags.recent ?? 3;
|
|
248
|
+
const rows = topLevelByThread(taskRepo, flags.thread).filter((t) => t.agent_id === agent).slice(0, recent + 1);
|
|
249
|
+
const analyses = rows.map((t) => (0, analyzer_js_1.analyzeTask)(t, spanRepo.findByTaskId(t.id)));
|
|
250
|
+
const latest = analyses[0] ?? null;
|
|
251
|
+
const previous = analyses.slice(1).map(analyzer_js_1.summarizeAnalysis);
|
|
252
|
+
const result = {
|
|
253
|
+
mode: 'continue',
|
|
254
|
+
thread: flags.thread,
|
|
255
|
+
agent,
|
|
256
|
+
latest,
|
|
257
|
+
previous,
|
|
258
|
+
};
|
|
259
|
+
if (flags.json) {
|
|
260
|
+
writeJson({
|
|
261
|
+
...result,
|
|
262
|
+
latest: latest ? jsonSafeAnalysis(latest, flags.full) : null,
|
|
263
|
+
});
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const body = (0, renderer_js_1.renderContinue)(result, {
|
|
267
|
+
maxTimeline: flags.full ? null : CONTINUE_LATEST_TIMELINE,
|
|
268
|
+
});
|
|
269
|
+
const actions = [];
|
|
270
|
+
const drill = previous[0]?.taskId ?? latest?.taskId;
|
|
271
|
+
if (drill) {
|
|
272
|
+
actions.push({ label: 'Full activity log', cmd: `crewx dreaming --task=${drill} --full` });
|
|
273
|
+
actions.push({ label: 'Detailed task log JSON', cmd: `crewx dreaming --task=${drill} --json` });
|
|
274
|
+
}
|
|
275
|
+
actions.push({
|
|
276
|
+
label: 'Task list for this conversation',
|
|
277
|
+
cmd: `crewx dreaming --thread=${flags.thread} --agent=${agent}`,
|
|
278
|
+
});
|
|
279
|
+
console.log(body + (actions.length ? '\n' + (0, renderer_js_1.buildCalFooter)(actions) : ''));
|
|
99
280
|
return;
|
|
100
281
|
}
|
|
101
282
|
if (flags.thread) {
|
|
102
283
|
const recent = flags.recent ?? 5;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.filter((t) =>
|
|
106
|
-
|
|
107
|
-
.slice(0, recent);
|
|
284
|
+
let topLevel = topLevelByThread(taskRepo, flags.thread);
|
|
285
|
+
if (agent)
|
|
286
|
+
topLevel = topLevel.filter((t) => t.agent_id === agent);
|
|
287
|
+
topLevel = topLevel.slice(0, recent);
|
|
108
288
|
const summaryRows = topLevel.map((t) => ({
|
|
109
289
|
taskId: t.id,
|
|
110
290
|
agentId: t.agent_id,
|
|
@@ -114,10 +294,21 @@ async function main(inputArgs) {
|
|
|
114
294
|
duration: t.duration_ms != null ? Math.round(t.duration_ms / 1000) : null,
|
|
115
295
|
}));
|
|
116
296
|
if (flags.json) {
|
|
117
|
-
|
|
297
|
+
writeJson(summaryRows);
|
|
118
298
|
return;
|
|
119
299
|
}
|
|
120
|
-
|
|
300
|
+
const list = (0, renderer_js_1.renderThreadTaskList)(summaryRows, flags.thread, recent);
|
|
301
|
+
const actions = [];
|
|
302
|
+
const first = summaryRows[0];
|
|
303
|
+
if (first) {
|
|
304
|
+
const agentArg = agent ?? first.agentId;
|
|
305
|
+
actions.push({
|
|
306
|
+
label: 'Continue previous work',
|
|
307
|
+
cmd: `crewx dreaming --thread=${flags.thread} --agent=${agentArg} --continue`,
|
|
308
|
+
});
|
|
309
|
+
actions.push({ label: 'Task drilldown', cmd: `crewx dreaming --task=${first.taskId} --full` });
|
|
310
|
+
}
|
|
311
|
+
console.log(list + (actions.length ? '\n' + (0, renderer_js_1.buildCalFooter)(actions) : ''));
|
|
121
312
|
return;
|
|
122
313
|
}
|
|
123
314
|
}
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA,YAAY,CAAC
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../cli.ts"],"names":[],"mappings":";AACA,YAAY,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwKb,oBAyKC;AA/UD,oCAA4D;AAE5D,uCAAyB;AACzB,2CAA6B;AAC7B,mDAAqF;AACrF,6CAA8C;AAC9C,mDAO2B;AAWd,QAAA,2BAA2B,GAAG,IAAI,CAAC;A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ACD,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,IAAA,4BAAc,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3E,OAAO;IACT,CAAC;AACH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAQ,EAAE,EAAE;QACxB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/analyzer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SpanRow, TaskRow } from '@crewx/sdk';
|
|
2
|
-
import type { TaskAnalysis } from './types.js';
|
|
2
|
+
import type { TaskAnalysis, TaskActivitySummary, ActivityLogEntry, ActivityLog } from './types.js';
|
|
3
3
|
export declare function normalizeToolName(name: string | null | undefined): string;
|
|
4
4
|
interface RawToolCall {
|
|
5
5
|
toolUseId: string | null;
|
|
@@ -10,5 +10,12 @@ interface RawToolCall {
|
|
|
10
10
|
}
|
|
11
11
|
export declare function extractToolCallsFromLogs(logs: unknown[]): RawToolCall[];
|
|
12
12
|
export declare function analyzeTask(row: TaskRow, spans: SpanRow[]): TaskAnalysis;
|
|
13
|
+
export declare const READ_ONLY_TOOLS: Set<string>;
|
|
14
|
+
export declare const READ_ONLY_BASH_PREFIXES: string[];
|
|
15
|
+
export declare function isReadOnlyToolCall(name: string, input: string | null): boolean;
|
|
16
|
+
export declare function checkFileStaleness(filePath: string, taskCompletedAt?: string | null): 'ok' | 'stale' | 'unknown';
|
|
17
|
+
export declare function extractActivityLogEntries(analyses: TaskAnalysis[]): ActivityLogEntry[];
|
|
18
|
+
export declare function buildActivityLog(analyses: TaskAnalysis[], threadId: string, agentId: string, lookback: number, tokenBudget: number): ActivityLog;
|
|
19
|
+
export declare function summarizeAnalysis(a: TaskAnalysis): TaskActivitySummary;
|
|
13
20
|
export {};
|
|
14
21
|
//# sourceMappingURL=analyzer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,KAAK,EAIV,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,WAAW,EACZ,MAAM,YAAY,CAAC;AA6BpB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAUzE;AAyDD,UAAU,WAAW;IACnB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACxB,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,WAAW,EAAE,CA6DvE;AAoLD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,YAAY,CAsExE;AAQD,eAAO,MAAM,eAAe,aAE1B,CAAC;AAMH,eAAO,MAAM,uBAAuB,EAAE,MAAM,EAc3C,CAAC;AAeF,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAY9E;AAID,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,CAWhH;AAyBD,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,YAAY,EAAE,GAAG,gBAAgB,EAAE,CAUtF;AAKD,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,YAAY,EAAE,EACxB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,WAAW,EAAE,MAAM,GAClB,WAAW,CAiBb;AAMD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,YAAY,GAAG,mBAAmB,CAoBtE"}
|
package/dist/src/analyzer.js
CHANGED
|
@@ -1,8 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.READ_ONLY_BASH_PREFIXES = exports.READ_ONLY_TOOLS = void 0;
|
|
3
37
|
exports.normalizeToolName = normalizeToolName;
|
|
4
38
|
exports.extractToolCallsFromLogs = extractToolCallsFromLogs;
|
|
5
39
|
exports.analyzeTask = analyzeTask;
|
|
40
|
+
exports.isReadOnlyToolCall = isReadOnlyToolCall;
|
|
41
|
+
exports.checkFileStaleness = checkFileStaleness;
|
|
42
|
+
exports.extractActivityLogEntries = extractActivityLogEntries;
|
|
43
|
+
exports.buildActivityLog = buildActivityLog;
|
|
44
|
+
exports.summarizeAnalysis = summarizeAnalysis;
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
6
46
|
const sdk_1 = require("@crewx/sdk");
|
|
7
47
|
const VERIFY_COMMANDS = [
|
|
8
48
|
'tsc', 'npm test', 'npm run test', 'npm run lint', 'eslint',
|
|
@@ -13,14 +53,14 @@ const BASH_ERROR_PATTERNS = [
|
|
|
13
53
|
/does not exist/i, /FAILED/, /✗/, /ERR!/,
|
|
14
54
|
];
|
|
15
55
|
const ERROR_CATEGORIES = [
|
|
16
|
-
[/Type .+ is not assignable to type/i, '
|
|
17
|
-
[/Cannot find module/i, '
|
|
18
|
-
[/Property .+ does not exist/i, '
|
|
19
|
-
[/Expected \d+ arguments/i, '
|
|
20
|
-
[/Cannot find name/i, '
|
|
21
|
-
[/has no exported member/i, 'export
|
|
22
|
-
[/FAIL|AssertionError|expect\(/i, '
|
|
23
|
-
[/SyntaxError|Unexpected token/i, '
|
|
56
|
+
[/Type .+ is not assignable to type/i, 'Type mismatch'],
|
|
57
|
+
[/Cannot find module/i, 'Module path error'],
|
|
58
|
+
[/Property .+ does not exist/i, 'Missing property'],
|
|
59
|
+
[/Expected \d+ arguments/i, 'Argument count mismatch'],
|
|
60
|
+
[/Cannot find name/i, 'Undeclared variable/function'],
|
|
61
|
+
[/has no exported member/i, 'Missing export'],
|
|
62
|
+
[/FAIL|AssertionError|expect\(/i, 'Test failure'],
|
|
63
|
+
[/SyntaxError|Unexpected token/i, 'Syntax error'],
|
|
24
64
|
];
|
|
25
65
|
const FILE_PLACEHOLDERS = new Set(['Read File', 'Edit File', 'Write File', 'Terminal', '{}', '']);
|
|
26
66
|
function normalizeToolName(name) {
|
|
@@ -392,6 +432,9 @@ function analyzeTask(row, spans) {
|
|
|
392
432
|
promptSummary,
|
|
393
433
|
resultSummary,
|
|
394
434
|
duration,
|
|
435
|
+
startedAt: row.started_at ?? null,
|
|
436
|
+
completedAt: row.completed_at ?? null,
|
|
437
|
+
durationMs: row.duration_ms ?? null,
|
|
395
438
|
toolCount: toolCalls.length,
|
|
396
439
|
timeline,
|
|
397
440
|
patterns,
|
|
@@ -411,4 +454,120 @@ function analyzeTask(row, spans) {
|
|
|
411
454
|
hasStruggles: patterns.struggles.length > 0,
|
|
412
455
|
};
|
|
413
456
|
}
|
|
457
|
+
exports.READ_ONLY_TOOLS = new Set([
|
|
458
|
+
'Read', 'Grep', 'Find', 'Glob',
|
|
459
|
+
]);
|
|
460
|
+
exports.READ_ONLY_BASH_PREFIXES = [
|
|
461
|
+
'git status', 'git log', 'git branch', 'git diff --stat', 'git show',
|
|
462
|
+
'git remote', 'git rev-parse', 'git ls-files',
|
|
463
|
+
'pwd', 'ls ', 'ls\n', 'echo ',
|
|
464
|
+
'cat ', 'head ', 'tail ',
|
|
465
|
+
'npx crewx memory index', 'npx crewx memory find', 'npx crewx memory get',
|
|
466
|
+
'npx crewx doc toc', 'npx crewx doc section', 'npx crewx doc status',
|
|
467
|
+
'npx crewx search',
|
|
468
|
+
'npx skill tsserver find', 'npx skill tsserver refs', 'npx skill tsserver type',
|
|
469
|
+
'crewx memory index', 'crewx memory find', 'crewx memory get',
|
|
470
|
+
'crewx doc toc', 'crewx doc section', 'crewx doc status',
|
|
471
|
+
'crewx search',
|
|
472
|
+
'crewx agent ls', 'crewx agent list',
|
|
473
|
+
'crewx wbs status',
|
|
474
|
+
];
|
|
475
|
+
const MUTATING_BASH_PATTERNS = [
|
|
476
|
+
/\bgit\s+(commit|push|pull|merge|rebase|reset|checkout|switch|add|rm)\b/,
|
|
477
|
+
/\bnpm\s+(install|ci|publish|run\s+(test|lint|build))\b/,
|
|
478
|
+
/\bnpx\s+tsc\b/,
|
|
479
|
+
/\bpnpm\s+(install|run)\b/,
|
|
480
|
+
/\bvitest\b/, /\bjest\b/,
|
|
481
|
+
];
|
|
482
|
+
function isReadOnlyToolCall(name, input) {
|
|
483
|
+
const normalized = normalizeToolName(name);
|
|
484
|
+
if (exports.READ_ONLY_TOOLS.has(normalized))
|
|
485
|
+
return true;
|
|
486
|
+
if (normalized !== 'Bash')
|
|
487
|
+
return false;
|
|
488
|
+
if (!input)
|
|
489
|
+
return false;
|
|
490
|
+
const firstLine = input.split('\n')[0].trimStart();
|
|
491
|
+
if (MUTATING_BASH_PATTERNS.some((re) => re.test(firstLine)))
|
|
492
|
+
return false;
|
|
493
|
+
return exports.READ_ONLY_BASH_PREFIXES.some((prefix) => firstLine.startsWith(prefix));
|
|
494
|
+
}
|
|
495
|
+
function checkFileStaleness(filePath, taskCompletedAt) {
|
|
496
|
+
try {
|
|
497
|
+
const stat = fs.statSync(filePath);
|
|
498
|
+
if (taskCompletedAt) {
|
|
499
|
+
const taskTime = Date.parse(taskCompletedAt);
|
|
500
|
+
if (!Number.isNaN(taskTime) && stat.mtimeMs > taskTime)
|
|
501
|
+
return 'stale';
|
|
502
|
+
}
|
|
503
|
+
return 'ok';
|
|
504
|
+
}
|
|
505
|
+
catch {
|
|
506
|
+
return 'unknown';
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
function toActivityLogEntry(e, taskCompletedAt) {
|
|
510
|
+
if (!isReadOnlyToolCall(e.name, e.input))
|
|
511
|
+
return null;
|
|
512
|
+
if (e.isError)
|
|
513
|
+
return null;
|
|
514
|
+
let filePath = null;
|
|
515
|
+
let status = 'ok';
|
|
516
|
+
if (e.name === 'Read' && e.filePath) {
|
|
517
|
+
const fp = Array.isArray(e.filePath) ? e.filePath[0] ?? null : e.filePath;
|
|
518
|
+
filePath = fp;
|
|
519
|
+
if (fp)
|
|
520
|
+
status = checkFileStaleness(fp, taskCompletedAt);
|
|
521
|
+
}
|
|
522
|
+
const cmd = e.name === 'Bash' ? (e.bashCmd ?? e.input?.slice(0, 150) ?? null) : (e.input?.slice(0, 150) ?? null);
|
|
523
|
+
return { tool: e.name, cmd, result: e.resultPreview ?? null, filePath, status };
|
|
524
|
+
}
|
|
525
|
+
function extractActivityLogEntries(analyses) {
|
|
526
|
+
const entries = [];
|
|
527
|
+
for (const a of analyses) {
|
|
528
|
+
for (const e of a.timeline) {
|
|
529
|
+
const entry = toActivityLogEntry(e, a.completedAt);
|
|
530
|
+
if (entry)
|
|
531
|
+
entries.push(entry);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
return entries;
|
|
535
|
+
}
|
|
536
|
+
function buildActivityLog(analyses, threadId, agentId, lookback, tokenBudget) {
|
|
537
|
+
const allEntries = extractActivityLogEntries(analyses);
|
|
538
|
+
const included = [];
|
|
539
|
+
let budgetUsed = 0;
|
|
540
|
+
let truncated = false;
|
|
541
|
+
for (const e of allEntries) {
|
|
542
|
+
const size = (e.result?.length ?? 0) + (e.cmd?.length ?? 0) + 80;
|
|
543
|
+
if (budgetUsed + size > tokenBudget && included.length > 0) {
|
|
544
|
+
truncated = true;
|
|
545
|
+
break;
|
|
546
|
+
}
|
|
547
|
+
included.push(e);
|
|
548
|
+
budgetUsed += size;
|
|
549
|
+
}
|
|
550
|
+
return { threadId, agentId, lookback, totalEntries: allEntries.length, entries: included, truncated, budgetUsed };
|
|
551
|
+
}
|
|
552
|
+
function summarizeAnalysis(a) {
|
|
553
|
+
const toolCounts = {};
|
|
554
|
+
for (const e of a.timeline) {
|
|
555
|
+
const name = e.name || '?';
|
|
556
|
+
toolCounts[name] = (toolCounts[name] ?? 0) + 1;
|
|
557
|
+
}
|
|
558
|
+
return {
|
|
559
|
+
taskId: a.taskId,
|
|
560
|
+
agentId: a.agentId,
|
|
561
|
+
status: a.status,
|
|
562
|
+
duration: a.duration,
|
|
563
|
+
startedAt: a.startedAt,
|
|
564
|
+
completedAt: a.completedAt,
|
|
565
|
+
toolCount: a.toolCount,
|
|
566
|
+
toolCounts,
|
|
567
|
+
editFiles: a.behavior.editFiles,
|
|
568
|
+
readFiles: a.behavior.readFiles,
|
|
569
|
+
hasStruggles: a.hasStruggles,
|
|
570
|
+
promptSummary: a.promptSummary,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
414
573
|
//# sourceMappingURL=analyzer.js.map
|