@crewx/dreaming 0.1.0-rc.18 → 0.1.0-rc.180

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 CHANGED
@@ -1,142 +1,143 @@
1
1
  ---
2
2
  name: crewx/dreaming
3
3
  description: >
4
- 선별 실행하는 필수 회고 스킬. 태스크/대화 단위로 에이전트 행동을 되돌아보는
5
- 1급 자기성찰 도구. memory/doc/search와 동급으로 상황 판단해 주도적으로 호출한다.
4
+ Essential retrospective skill invoked selectively. A first-class self-reflection
5
+ tool for reviewing agent behavior at the task/conversation level. On par with
6
+ memory/doc/search — the agent judges the situation and calls it proactively.
6
7
  metadata:
7
8
  version: 0.1.0
8
9
  built-in: true
9
10
  ---
10
11
 
11
- # Dreaming — 필수 회고 스킬
12
+ # Dreaming — Essential Retrospective Skill
12
13
 
13
- **dreaming은 에이전트의 1급 자기성찰 도구다.**
14
- memory(기억 저장/검색), doc(설계서 탐색), search(코드 검색)와 동급으로,
15
- 에이전트가 상황을 판단해 **스스로 호출**한다. 수동 요청이 오기를 기다리지 않는다.
14
+ **dreaming is the agent's first-class self-reflection tool.**
15
+ On par with memory (store/search memories), doc (explore design docs), and search (search code),
16
+ the agent judges the situation and **calls it on its own** — it doesn't wait for a manual request.
16
17
 
17
- ## 두 가지 시야
18
+ ## Two Views
18
19
 
19
- | 명령어 | 시야 | 쓰는 때 |
20
+ | Command | View | When to use |
20
21
  |--------|------|---------|
21
- | `crewx dreaming --task=tsk_xxx` | 돋보기 | 태스크 1건을 깊게 — 행동 타임라인, 삽질 패턴, 효율 패턴, 스킬 사용 현황 |
22
- | `crewx dreaming --thread=thd_xxx --recent=N` | 지도 | 대화 내 최근 N개 태스크 목록 + 각 종료상태 |
23
- | `crewx dreaming --thread=thd_xxx --agent=self --continue` | 이어보기 | 내 직전 작업 1건 상세 + 그 이전 N건 규칙 기반 요약 |
22
+ | `crewx dreaming --task=tsk_xxx` | Magnifier | Deep dive into one task — action timeline, struggle patterns, efficiency patterns, skill usage |
23
+ | `crewx dreaming --thread=thd_xxx --recent=N` | Map | List of the last N tasks in the conversation + each one's end status |
24
+ | `crewx dreaming --thread=thd_xxx --agent=self --continue` | Continue | Detail on my most recent task + rule-based summary of the N before it |
24
25
 
25
- ## 언제 호출할까 (에이전트 판단 기준)
26
+ ## When To Call It (Agent Judgment Criteria)
26
27
 
27
- - **작업 시작 전**: 방금 끊긴 태스크가 있는지 확인 → `--thread` 목록 확인
28
- - **실패 태스크 재시도**: 직전에 어디까지 하다 멈췄는지 → `--task` 로 타임라인 확인
29
- - **대화 맥락 파악**: 이 대화에서 뭘 시켰는지 목록으로 파악 → `--thread --recent=5`
30
- - **작업 후 자기 점검**: 삽질 패턴 / 효율 패턴 확인 → `--task` 로 회고
28
+ - **Before starting work**: Check whether a task was just interrupted → check the `--thread` list
29
+ - **Retrying a failed task**: See where it stopped last time → check the timeline with `--task`
30
+ - **Understanding conversation context**: Get a list of what was asked in this conversation → `--thread --recent=5`
31
+ - **Self-check after a task**: Check for struggle patterns / efficiency patterns → retrospect with `--task`
31
32
 
32
- ## 사용법
33
+ ## Usage
33
34
 
34
35
  ```bash
35
- # 태스크 1건 깊이 회고
36
+ # Deep retrospective on one task
36
37
  crewx dreaming --task=tsk_abc123
37
38
 
38
- # 대화 내 최근 5건 목록 (기본값)
39
+ # List of the last 5 in the conversation (default)
39
40
  crewx dreaming --thread=thd_xyz789
40
41
 
41
- # 더 많이 보기
42
+ # See more
42
43
  crewx dreaming --thread=thd_xyz789 --recent=20
43
44
 
44
- # 특정 태스크 드릴다운
45
+ # Drill down into a specific task
45
46
  crewx dreaming --task=tsk_abc123 --json
46
47
  ```
47
48
 
48
- ## 출력 예시 — --task 모드
49
+ ## Output Example — --task Mode
49
50
 
50
51
  ```
51
52
  ━━━ Dreaming: task tsk_abc123 ━━━
52
53
  Agent: core_dev (acp/claude) | Status: success | Duration: 312s | Tools: 47 calls
53
- 📋 지시: dreaming 빌트인 승격 작업
54
- 📝 결론: packages/built-in/dreaming/ 생성 완료
54
+ 📋 Instruction: promote dreaming to a built-in skill
55
+ 📝 Conclusion: packages/built-in/dreaming/ created successfully
55
56
 
56
- [타임라인]
57
+ [Timeline]
57
58
  1. Read packages/built-in/memory/package.json
58
59
  2. Read packages/built-in/doc/tsconfig.json
59
60
  3. Edit packages/built-in/dreaming/package.json
60
61
  ...
61
62
  41. Bash npx tsc --noEmit → ❌ error TS2345
62
- 42. Edit packages/built-in/dreaming/src/analyzer.ts ← 같은 파일 재수정
63
+ 42. Edit packages/built-in/dreaming/src/analyzer.ts ← re-edited the same file
63
64
  43. Bash npx tsc --noEmit → ✅ pass
64
- 💡 삽질: analyzer.ts 2회 수정 (41→43) — 타입 불일치
65
+ 💡 Struggle: edited analyzer.ts twice (41→43) — type mismatch
65
66
 
66
- [스킬 사용]
67
- crewx/memory 3회 (index, find, save)
68
- crewx/doc 2회 (toc, section)
67
+ [Skill Usage]
68
+ crewx/memory 3x (index, find, save)
69
+ crewx/doc 2x (toc, section)
69
70
 
70
- [회고 요약]
71
- ⚠️ 삽질 패턴: 같은 파일 반복 수정 1건 (analyzer.ts 2회)
72
- 💡 인사이트: 에러 대부분 타입 불일치 (1건)
73
- 🔍 코드 분석 활용 — tsserver 5회 사용
71
+ [Retrospective Summary]
72
+ ⚠️ Struggle pattern: repeated edits to the same file, 1 case (analyzer.ts x2)
73
+ 💡 Insight: most errors were type mismatches (1 case)
74
+ 🔍 Used code analysis — tsserver called 5x
74
75
  ```
75
76
 
76
- ## 출력 예시 — --thread 모드
77
+ ## Output Example — --thread Mode
77
78
 
78
79
  ```
79
- ━━━ Dreaming: thread thd_xyz789 — 최근 5건 ━━━
80
- 태스크 목록: 5건
80
+ ━━━ Dreaming: thread thd_xyz789 — last 5 ━━━
81
+ Task list: 5
81
82
 
82
- 1. ✅ tsk_abc123 | core_dev | success | 312s | dreaming 빌트인 승격 작업
83
- 2. ❌ tsk_def456 | core_dev | failed | 45s | tsc 빌드 검증
84
- 3. ✅ tsk_ghi789 | ui_lead | completed | 180s | UI 컴포넌트 리뷰
85
- 4. ✅ tsk_jkl012 | core_dev | success | 240s | SDK 리포지토리 패턴 적용
86
- 5. ✅ tsk_mno345 | core_dev | success | 90s | CLI registry 등록
83
+ 1. ✅ tsk_abc123 | core_dev | success | 312s | promote dreaming to a built-in skill
84
+ 2. ❌ tsk_def456 | core_dev | failed | 45s | tsc build verification
85
+ 3. ✅ tsk_ghi789 | ui_lead | completed | 180s | UI component review
86
+ 4. ✅ tsk_jkl012 | core_dev | success | 240s | apply SDK repository pattern
87
+ 5. ✅ tsk_mno345 | core_dev | success | 90s | register CLI registry
87
88
 
88
- 드릴다운: crewx dreaming --task=<id>
89
+ Drill down: crewx dreaming --task=<id>
89
90
  ```
90
91
 
91
- ## 출력 예시 — --continue 모드 (이전 내 작업 이어보기)
92
+ ## Output Example — --continue Mode (Continue My Previous Work)
92
93
 
93
- 같은 thread 안에서 **현재 agent 자신의** 이전 작업만 골라, 최신 1건은 자세히 + 그 이전은 규칙 기반 한 줄 요약으로 보여준다. 요약은 LLM이 아니라 tool count / status / duration / files 기반이다.
94
+ Within the same thread, this picks out only the **current agent's own** previous work, showing the most recent one in detail plus rule-based one-line summaries of the ones before it. The summaries are based on tool count / status / duration / files, not an LLM.
94
95
 
95
96
  ```
96
- ━━━ 이전 내 작업 이어보기 ━━━
97
+ ━━━ Continue My Previous Work ━━━
97
98
  Thread: thd_xyz789 | Agent: core_lead
98
99
 
99
- [직전 작업]
100
+ [Most Recent Task]
100
101
 
101
102
  ━━━ Dreaming: task tsk_123 ━━━
102
- ... 자세한 활동 기록 (타임라인 캡 30, --full로 해제) ...
103
+ ... detailed activity log (timeline capped at 30, remove with --full) ...
103
104
 
104
- [이전 작업 요약]
105
- - tsk_122 | ✅ success | 120s | Bash 3회, Read 4회, Edit 0회
106
- - tsk_121 | ❌ failed | 45s | Bash 2회 | ⚠️ 삽질
105
+ [Previous Task Summary]
106
+ - tsk_122 | ✅ success | 120s | Bash 3x, Read 4x, Edit 0x
107
+ - tsk_121 | ❌ failed | 45s | Bash 2x | ⚠️ struggle
107
108
 
108
- ━━━ 다음 액션 ━━━
109
- 전체 활동 기록:
109
+ ━━━ Next Actions ━━━
110
+ Full activity log:
110
111
  crewx dreaming --task=tsk_122 --full
111
- 상세 작업 기록 JSON:
112
+ Detailed task log JSON:
112
113
  crewx dreaming --task=tsk_122 --json
113
- 이 대화 작업 목록:
114
+ Task list for this conversation:
114
115
  crewx dreaming --thread=thd_xyz789 --agent=core_lead
115
116
  ```
116
117
 
117
118
  ```bash
118
- # 현재 agent 자신의 이전 작업 이어보기
119
+ # Continue the current agent's own previous work
119
120
  crewx dreaming --thread=thd_xyz789 --agent=self --continue
120
121
 
121
- # 명시 agent + 최근 3건 (최신 1 상세 + 이전 2 요약)
122
+ # Explicit agent + last 3 (most recent 1 detailed + previous 2 summarized)
122
123
  crewx dreaming --thread=thd_xyz789 --agent=core_lead --continue --recent=3
123
124
  ```
124
125
 
125
- > `--agent=self` 는 `CREWX_AGENT_ID` 환경변수로 현재 agent를 해석한다. 환경변수가 없으면 명시 agent id를 써야 한다.
126
+ > `--agent=self` resolves the current agent via the `CREWX_AGENT_ID` environment variable. If the variable isn't set, you must specify an explicit agent id.
126
127
 
127
128
  ## Options
128
129
 
129
- | 옵션 | 기본값 | 설명 |
130
+ | Option | Default | Description |
130
131
  |------|--------|------|
131
- | `--task=ID` | — | 태스크 ID (tsk_xxx) |
132
- | `--thread=ID` | — | 스레드 ID (thd_xxx) |
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에서 원본 입력/결과 필드를 제외한다.
132
+ | `--task=ID` | — | Task ID (tsk_xxx) |
133
+ | `--thread=ID` | — | Thread ID (thd_xxx) |
134
+ | `--agent=ID` | — | Only this agent within the thread (`self` → current agent) |
135
+ | `--continue` | false | Continue my previous work (most recent 1 detailed + previous N rule-based summary) |
136
+ | `--recent=N` | list 5 / continue 3 | Last N items |
137
+ | `--full` | false | Remove the timeline cap + include raw fields in JSON |
138
+ | `--json` | false | Pure JSON output (no CAL footer) |
139
+
140
+ ## CAL "Next Actions"
141
+
142
+ A CAL footer guiding the next action is appended to the bottom of human-readable output (`--full`, `--json`, thread drill-down).
143
+ **The `--json` output has no footer and can be parsed as a single JSON value.** Without `--full`, the raw input/result fields are excluded from the JSON.
package/dist/cli.d.ts CHANGED
@@ -1,3 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import { TaskRepository } from '@crewx/sdk';
3
+ import type { TaskLogEntry } from '@crewx/sdk/repository';
4
+ export declare const DEFAULT_ACTIVITY_LOG_BUDGET = 8000;
5
+ export declare function readCanonicalTaskLogs(taskRepo: Pick<TaskRepository, 'readLogs'>, taskId: string): TaskLogEntry[];
2
6
  export declare function main(inputArgs?: string[]): Promise<void>;
3
- //# sourceMappingURL=cli.d.ts.map
7
+
package/dist/cli.js CHANGED
@@ -1,233 +1,38 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.main = main;
5
- const sdk_1 = require("@crewx/sdk");
6
- const analyzer_js_1 = require("./src/analyzer.js");
7
- const scrub_js_1 = require("./src/scrub.js");
8
- const renderer_js_1 = require("./src/renderer.js");
9
- const DEFAULT_TASK_TIMELINE = 60;
10
- const CONTINUE_LATEST_TIMELINE = 30;
11
- function parseFlags(argv) {
12
- const flags = {
13
- task: null,
14
- thread: null,
15
- agent: null,
16
- days: 1,
17
- recent: null,
18
- json: false,
19
- all: false,
20
- continue: false,
21
- full: false,
22
- };
23
- for (const a of argv) {
24
- if (a === '--json')
25
- flags.json = true;
26
- else if (a === '--all')
27
- flags.all = true;
28
- else if (a === '--full')
29
- flags.full = true;
30
- else if (a === '--continue')
31
- flags.continue = true;
32
- else if (a.startsWith('--task='))
33
- flags.task = a.slice('--task='.length);
34
- else if (a.startsWith('--thread='))
35
- flags.thread = a.slice('--thread='.length);
36
- else if (a.startsWith('--agent='))
37
- flags.agent = a.slice('--agent='.length);
38
- else if (a.startsWith('--days='))
39
- flags.days = parseInt(a.slice('--days='.length), 10);
40
- else if (a.startsWith('--recent='))
41
- flags.recent = parseInt(a.slice('--recent='.length), 10);
42
- else if (a === '--help' || a === '-h') {
43
- printUsage();
44
- process.exit(0);
45
- }
46
- else if (a.startsWith('--')) {
47
- console.error(`Unknown option: ${a}\nRun with --help for usage.`);
48
- process.exit(1);
49
- }
50
- }
51
- return flags;
52
- }
53
- function printUsage() {
54
- console.log(`crewx dreaming — 선별 실행하는 필수 회고 스킬
2
+ "use strict";var j=exports&&exports.__createBinding||(Object.create?(function(r,t,e,n){if(n===void 0)n=e;var s=Object.getOwnPropertyDescriptor(t,e);if(!s||("get"in s?!t.__esModule:s.writable||s.configurable)){s={enumerable:true,get:function(){return t[e]}}}Object.defineProperty(r,n,s)}):(function(r,t,e,n){if(n===void 0)n=e;r[n]=t[e]}));var E=exports&&exports.__setModuleDefault||(Object.create?(function(r,t){Object.defineProperty(r,"default",{enumerable:true,value:t})}):function(r,t){r["default"]=t});var T=exports&&exports.__importStar||(function(){var r=function(t){r=Object.getOwnPropertyNames||function(e){var n=[];for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s))n[n.length]=s;return n};return r(t)};return function(t){if(t&&t.__esModule)return t;var e={};if(t!=null){for(var n=r(t),s=0;s<n.length;s++)if(n[s]!=="default")j(e,t,n[s])}E(e,t);return e}})();Object.defineProperty(exports,"__esModule",{value:true});exports.DEFAULT_ACTIVITY_LOG_BUDGET=void 0;exports.readCanonicalTaskLogs=D;exports.main=A;const b=require("@crewx/sdk");const I=T(require("fs"));const L=T(require("path"));const k=require("./src/analyzer.js");const N=require("./src/scrub.js");const d=require("./src/renderer.js");exports.DEFAULT_ACTIVITY_LOG_BUDGET=8e3;const O=60;const S=30;function C(r){const t={task:null,thread:null,agent:null,days:1,recent:null,json:false,all:false,continue:false,full:false,lookback:3,activityLog:false};for(const e of r){if(e==="--json")t.json=true;else if(e==="--all")t.all=true;else if(e==="--full")t.full=true;else if(e==="--continue")t.continue=true;else if(e==="--activity-log")t.activityLog=true;else if(e.startsWith("--task="))t.task=e.slice("--task=".length);else if(e.startsWith("--thread="))t.thread=e.slice("--thread=".length);else if(e.startsWith("--agent="))t.agent=e.slice("--agent=".length);else if(e.startsWith("--days="))t.days=parseInt(e.slice("--days=".length),10);else if(e.startsWith("--recent="))t.recent=parseInt(e.slice("--recent=".length),10);else if(e.startsWith("--lookback="))t.lookback=parseInt(e.slice("--lookback=".length),10);else if(e==="--help"||e==="-h"){y();process.exit(0)}else if(e.startsWith("--")){console.error(`Unknown option: ${e}
3
+ Run with --help for usage.`);process.exit(1)}}return t}function y(){console.log(`crewx dreaming \u2014 Selective reflection skill
55
4
 
56
- 에이전트가 작업 전/후, 재시도 시 상황을 파악하기 위해 호출하는 1급 자기성찰 도구.
57
- memory/doc/search와 동급으로, 상황에 따라 주도적으로 실행한다.
5
+ A first-class reflection tool agents call before/after work or during retries to recover context.
6
+ Use it proactively alongside memory/doc/search when the situation calls for it.
58
7
 
59
8
  Usage:
60
9
  crewx dreaming --task=TASK_ID [--full] [--json]
61
10
  crewx dreaming --thread=THREAD_ID [--agent=AGENT_ID] [--recent=N]
62
11
  crewx dreaming --thread=THREAD_ID --agent=AGENT_ID --continue [--recent=N] [--full] [--json]
12
+ crewx dreaming --thread=THREAD_ID --agent=AGENT_ID --activity-log [--lookback=N] [--json]
63
13
 
64
14
  Options:
65
- --task=ID 태스크 1건 깊이 회고 (행동 타임라인 + 스킬 사용 + 삽질/효율 요약)
66
- --thread=ID 대화 내 최근 N개 태스크 목록 + 각 종료상태
67
- --agent=ID thread 안에서 특정 agent의 작업만 (--agent=self → 현재 agent)
68
- --continue 이전 내 작업 이어보기 — 최신 1건 상세 + 이전 N건 규칙 기반 요약
69
- --recent=N 최근 N건 (목록: 기본 5 / continue: 기본 3)
70
- --full 타임라인 전체 표시 (캡 해제) + JSON에 raw 필드 포함
71
- --json 순수 JSON 출력 (CAL footer 없음)
72
- --help, -h 도움말
15
+ --task=ID Deep reflection for one task (timeline + skill usage + struggle/efficiency summary)
16
+ --thread=ID List the last N tasks in a conversation with each end status
17
+ --agent=ID Restrict thread view to one agent (--agent=self means current agent)
18
+ --continue Continue previous work: latest task details plus rule-based summary of prior tasks
19
+ --activity-log Output precomputed <activity_log> XML of read-only results from previous N tasks
20
+ --lookback=N N-back depth for --activity-log (default: 3, 0 = disabled, max recommended: 5)
21
+ --recent=N Last N items (list default: 5 / continue default: 3)
22
+ --full Show the full timeline and include raw fields in JSON
23
+ --json Pure JSON output without a CAL footer
24
+ --help, -h Show help
73
25
 
74
- 언제 호출할까:
75
- - 작업 시작 전: 방금 끊긴 태스크가 있는지 확인
76
- - 실패 재시도 전: 직전에 어디까지 하다 멈췄는지 확인
77
- - 대화 맥락 파악: --thread 로 이 대화에서 뭘 시켰는지 목록 확인
78
- - 이전 내 작업 이어보기: --thread --agent --continue
26
+ When to call:
27
+ - Before starting: check whether there is an interrupted task
28
+ - Before retrying after failure: recover where the previous attempt stopped
29
+ - To understand conversation context: use --thread to list tasks in this conversation
30
+ - Continue previous work: --thread --agent --continue
31
+ - SDK prompt assembly: --activity-log to inject precomputed read-only results
79
32
 
80
33
  Examples:
81
34
  crewx dreaming --task=tsk_abc123 --full
82
35
  crewx dreaming --thread=thd_xyz789 --recent=5
83
36
  crewx dreaming --thread=thd_xyz789 --agent=core_lead --continue
84
- `);
85
- }
86
- function resolveAgent(agent) {
87
- if (agent !== 'self')
88
- return agent;
89
- const envAgent = process.env.CREWX_AGENT_ID;
90
- if (!envAgent) {
91
- console.error('Error: --agent=self requires CREWX_AGENT_ID in the environment.\n' +
92
- 'Pass an explicit agent id instead, e.g. --agent=core_lead.');
93
- process.exit(1);
94
- }
95
- return envAgent;
96
- }
97
- function jsonSafeAnalysis(a, full) {
98
- if (full)
99
- return a;
100
- return {
101
- ...a,
102
- timeline: a.timeline.map((e) => {
103
- const { input: _input, resultPreview: _resultPreview, ...rest } = e;
104
- return rest;
105
- }),
106
- };
107
- }
108
- function writeJson(obj) {
109
- process.stdout.write(JSON.stringify((0, scrub_js_1.scrubSecrets)(obj), null, 2) + '\n');
110
- }
111
- function topLevelByThread(taskRepo, threadId) {
112
- return taskRepo
113
- .findTasksByThread(threadId)
114
- .filter((t) => !t.parent_task_id)
115
- .sort((a, b) => (b.started_at > a.started_at ? 1 : -1));
116
- }
117
- async function main(inputArgs) {
118
- const args = inputArgs ?? process.argv.slice(2);
119
- if (!args.length || args[0] === '--help' || args[0] === '-h') {
120
- printUsage();
121
- return;
122
- }
123
- const flags = parseFlags(args);
124
- const agent = resolveAgent(flags.agent);
125
- if (!flags.task && !flags.thread) {
126
- console.error('Error: --task=<id> or --thread=<id> is required.\nRun crewx dreaming --help for usage.');
127
- process.exit(1);
128
- }
129
- const taskRepo = new sdk_1.TaskRepository();
130
- const spanRepo = new sdk_1.SpanRepository();
131
- if (flags.task) {
132
- const row = taskRepo.getTask(flags.task);
133
- if (!row) {
134
- console.log(`No task found: ${flags.task}`);
135
- return;
136
- }
137
- const spans = spanRepo.findByTaskId(flags.task);
138
- const result = (0, analyzer_js_1.analyzeTask)(row, spans);
139
- if (flags.json) {
140
- writeJson(jsonSafeAnalysis(result, flags.full));
141
- return;
142
- }
143
- const detail = (0, renderer_js_1.renderTaskFull)(result, {
144
- maxTimeline: flags.full ? null : DEFAULT_TASK_TIMELINE,
145
- });
146
- const actions = [];
147
- if (!flags.full) {
148
- actions.push({ label: '전체 활동 기록', cmd: `crewx dreaming --task=${result.taskId} --full` });
149
- }
150
- actions.push({ label: '상세 작업 기록 JSON', cmd: `crewx dreaming --task=${result.taskId} --json` });
151
- console.log(detail + '\n' + (0, renderer_js_1.buildCalFooter)(actions));
152
- return;
153
- }
154
- if (flags.thread && flags.continue) {
155
- if (!agent) {
156
- console.error('Error: --continue requires --agent=<id> (or --agent=self).');
157
- process.exit(1);
158
- }
159
- const recent = flags.recent ?? 3;
160
- const rows = topLevelByThread(taskRepo, flags.thread).filter((t) => t.agent_id === agent).slice(0, recent + 1);
161
- const analyses = rows.map((t) => (0, analyzer_js_1.analyzeTask)(t, spanRepo.findByTaskId(t.id)));
162
- const latest = analyses[0] ?? null;
163
- const previous = analyses.slice(1).map(analyzer_js_1.summarizeAnalysis);
164
- const result = {
165
- mode: 'continue',
166
- thread: flags.thread,
167
- agent,
168
- latest,
169
- previous,
170
- };
171
- if (flags.json) {
172
- writeJson({
173
- ...result,
174
- latest: latest ? jsonSafeAnalysis(latest, flags.full) : null,
175
- });
176
- return;
177
- }
178
- const body = (0, renderer_js_1.renderContinue)(result, {
179
- maxTimeline: flags.full ? null : CONTINUE_LATEST_TIMELINE,
180
- });
181
- const actions = [];
182
- const drill = previous[0]?.taskId ?? latest?.taskId;
183
- if (drill) {
184
- actions.push({ label: '전체 활동 기록', cmd: `crewx dreaming --task=${drill} --full` });
185
- actions.push({ label: '상세 작업 기록 JSON', cmd: `crewx dreaming --task=${drill} --json` });
186
- }
187
- actions.push({
188
- label: '이 대화 작업 목록',
189
- cmd: `crewx dreaming --thread=${flags.thread} --agent=${agent}`,
190
- });
191
- console.log(body + (actions.length ? '\n' + (0, renderer_js_1.buildCalFooter)(actions) : ''));
192
- return;
193
- }
194
- if (flags.thread) {
195
- const recent = flags.recent ?? 5;
196
- let topLevel = topLevelByThread(taskRepo, flags.thread);
197
- if (agent)
198
- topLevel = topLevel.filter((t) => t.agent_id === agent);
199
- topLevel = topLevel.slice(0, recent);
200
- const summaryRows = topLevel.map((t) => ({
201
- taskId: t.id,
202
- agentId: t.agent_id,
203
- status: t.status,
204
- promptSummary: t.prompt ? t.prompt.split('\n')[0].slice(0, 100) : null,
205
- startedAt: t.started_at,
206
- duration: t.duration_ms != null ? Math.round(t.duration_ms / 1000) : null,
207
- }));
208
- if (flags.json) {
209
- writeJson(summaryRows);
210
- return;
211
- }
212
- const list = (0, renderer_js_1.renderThreadTaskList)(summaryRows, flags.thread, recent);
213
- const actions = [];
214
- const first = summaryRows[0];
215
- if (first) {
216
- const agentArg = agent ?? first.agentId;
217
- actions.push({
218
- label: '이전 내 작업 이어보기',
219
- cmd: `crewx dreaming --thread=${flags.thread} --agent=${agentArg} --continue`,
220
- });
221
- actions.push({ label: '태스크 드릴다운', cmd: `crewx dreaming --task=${first.taskId} --full` });
222
- }
223
- console.log(list + (actions.length ? '\n' + (0, renderer_js_1.buildCalFooter)(actions) : ''));
224
- return;
225
- }
226
- }
227
- if (require.main === module) {
228
- main().catch((e) => {
229
- console.error(e.message);
230
- process.exit(1);
231
- });
232
- }
233
- //# sourceMappingURL=cli.js.map
37
+ crewx dreaming --thread=thd_xyz789 --agent=core_lead --activity-log --lookback=2
38
+ `)}function R(){const r=L.join(__dirname,"..","SKILL.md");if(I.existsSync(r)){process.stdout.write(I.readFileSync(r,"utf-8"))}else{y()}}function U(r){if(r!=="self")return r;const t=process.env.CREWX_AGENT_ID;if(!t){console.error("Error: --agent=self requires CREWX_AGENT_ID in the environment.\nPass an explicit agent id instead, e.g. --agent=core_lead.");process.exit(1)}return t}function x(r,t){if(t)return r;return{...r,timeline:r.timeline.map(e=>{const{input:n,resultPreview:s,...g}=e;return g})}}function p(r){process.stdout.write(JSON.stringify((0,N.scrubSecrets)(r),null,2)+"\n")}function v(r,t){return r.findTasksByThread(t).filter(e=>!e.parent_task_id).sort((e,n)=>n.started_at>e.started_at?1:-1)}function D(r,t){try{return r.readLogs(t)?.entries??[]}catch{return[]}}function w(r,t,e){return(0,k.analyzeTask)(e,t.findByTaskId(e.id),D(r,e.id))}async function A(r){const t=r??process.argv.slice(2);if(t[0]==="usage"){R();return}if(!t.length||t[0]==="--help"||t[0]==="-h"){y();return}const e=C(t);const n=U(e.agent);if(!e.task&&!e.thread){console.error("Error: --task=<id> or --thread=<id> is required.\nRun crewx dreaming --help for usage.");process.exit(1)}const s=new b.TaskRepository;const g=new b.SpanRepository;if(e.task){const l=s.getTask(e.task);if(!l){console.log(`No task found: ${e.task}`);return}const a=w(s,g,l);if(e.json){p(x(a,e.full));return}const u=(0,d.renderTaskFull)(a,{maxTimeline:e.full?null:O});const i=[];if(!e.full){i.push({label:"Full activity log",cmd:`crewx dreaming --task=${a.taskId} --full`})}i.push({label:"Detailed task log JSON",cmd:`crewx dreaming --task=${a.taskId} --json`});console.log(u+"\n"+(0,d.buildCalFooter)(i));return}if(e.thread&&e.activityLog){if(!n){console.error("Error: --activity-log requires --agent=<id> (or --agent=self).");process.exit(1)}const l=e.lookback;if(l===0){if(e.json){p({mode:"activity-log",lookback:0,entries:[],truncated:false,xml:""})}else{process.stdout.write("")}return}const a=v(s,e.thread).filter(c=>c.agent_id===n).slice(0,Math.min(l,5));const u=a.map(c=>w(s,g,c));const i=(0,k.buildActivityLog)(u,e.thread,n,l,exports.DEFAULT_ACTIVITY_LOG_BUDGET);if(e.json){p({mode:"activity-log",...i,xml:(0,d.renderActivityLogXml)(i)});return}process.stdout.write((0,d.renderActivityLogXml)(i)+"\n");return}if(e.thread&&e.continue){if(!n){console.error("Error: --continue requires --agent=<id> (or --agent=self).");process.exit(1)}const l=e.recent??3;const a=v(s,e.thread).filter(_=>_.agent_id===n).slice(0,l+1);const u=a.map(_=>w(s,g,_));const i=u[0]??null;const c=u.slice(1).map(k.summarizeAnalysis);const f={mode:"continue",thread:e.thread,agent:n,latest:i,previous:c};if(e.json){p({...f,latest:i?x(i,e.full):null});return}const o=(0,d.renderContinue)(f,{maxTimeline:e.full?null:S});const h=[];const m=c[0]?.taskId??i?.taskId;if(m){h.push({label:"Full activity log",cmd:`crewx dreaming --task=${m} --full`});h.push({label:"Detailed task log JSON",cmd:`crewx dreaming --task=${m} --json`})}h.push({label:"Task list for this conversation",cmd:`crewx dreaming --thread=${e.thread} --agent=${n}`});console.log(o+(h.length?"\n"+(0,d.buildCalFooter)(h):""));return}if(e.thread){const l=e.recent??5;let a=v(s,e.thread);if(n)a=a.filter(o=>o.agent_id===n);a=a.slice(0,l);const u=a.map(o=>({taskId:o.id,agentId:o.agent_id,status:o.status,promptSummary:o.prompt?o.prompt.split("\n")[0].slice(0,100):null,startedAt:o.started_at,duration:o.duration_ms!=null?Math.round(o.duration_ms/1e3):null}));if(e.json){p(u);return}const i=(0,d.renderThreadTaskList)(u,e.thread,l);const c=[];const f=u[0];if(f){const o=n??f.agentId;c.push({label:"Continue previous work",cmd:`crewx dreaming --thread=${e.thread} --agent=${o} --continue`});c.push({label:"Task drilldown",cmd:`crewx dreaming --task=${f.taskId} --full`})}console.log(i+(c.length?"\n"+(0,d.buildCalFooter)(c):""));return}}if(require.main===module){A().catch(r=>{console.error(r.message);process.exit(1)})}
@@ -1,5 +1,5 @@
1
1
  import type { SpanRow, TaskRow } from '@crewx/sdk';
2
- import type { TaskAnalysis, TaskActivitySummary } 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;
@@ -8,8 +8,14 @@ interface RawToolCall {
8
8
  isError: boolean | null;
9
9
  resultPreview: string | null;
10
10
  }
11
- export declare function extractToolCallsFromLogs(logs: unknown[]): RawToolCall[];
12
- export declare function analyzeTask(row: TaskRow, spans: SpanRow[]): TaskAnalysis;
11
+ export declare function extractToolCallsFromLogs(logs: unknown[], metaProvider?: string): RawToolCall[];
12
+ export declare function analyzeTask(row: TaskRow, spans: SpanRow[], logs?: unknown[]): 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;
13
19
  export declare function summarizeAnalysis(a: TaskAnalysis): TaskActivitySummary;
14
20
  export {};
15
- //# sourceMappingURL=analyzer.d.ts.map
21
+