cdsa-harness 0.1.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +106 -44
- package/package.json +2 -2
- package/src/cli.js +321 -64
- package/src/config.js +23 -4
- package/src/llm.js +188 -49
- package/src/loop.js +65 -8
- package/src/plugins.js +191 -0
- package/src/skills.js +61 -0
- package/src/tools.js +43 -3
- package/workspace/.cdsa/plugins/word_count.mjs +31 -0
- package/workspace/.cdsa/skills/summarize.md +5 -0
package/README.md
CHANGED
|
@@ -1,81 +1,146 @@
|
|
|
1
|
-
# CDSA Harness (Node.js CLI)
|
|
1
|
+
# CDSA Harness (Node.js CLI) 🎓⌨️
|
|
2
2
|
|
|
3
|
-
>
|
|
4
|
-
>
|
|
5
|
-
|
|
6
|
-
시작하면 ASCII 배너가 뜨고, **Agent Loop** 의 모든 단계가 색으로 흐릅니다.
|
|
3
|
+
> **AI 에이전트가 내부에서 실제로 뭘 하는지** 단계별로 드러내는 교육용 터미널 하네스.
|
|
4
|
+
> Claude Code·Codex 는 과정을 숨기지만, CDSA Harness 는 **컨텍스트 구성 → API 요청 → 모델의 판단 → 토큰/응답시간 → 도구 실행 → 결과 되먹임**을 전부 펼쳐 보여줍니다.
|
|
7
5
|
|
|
8
6
|
```
|
|
9
|
-
입력 →
|
|
7
|
+
① 입력 → ② LLM 호출(보낼 컨텍스트·도구) → ③ 모델 응답(토큰·지연·tool_call)
|
|
8
|
+
→ ④ 도구 판단 → ⑤ 실행/승인 → ⑥ 결과 되먹임 → (반복)
|
|
10
9
|
```
|
|
11
10
|
|
|
12
|
-
- **의존성 0개** — Node 18+ 내장 기능만
|
|
13
|
-
-
|
|
11
|
+
- **의존성 0개** — Node 18+ 내장 기능만(`fetch`/`readline`/`node:test`)
|
|
12
|
+
- **실제 LLM 연결** — OpenAI · Anthropic(Claude) · OpenRouter, 또는 키 없이 `mock`
|
|
13
|
+
- **교육 모드** — 매 반복마다 모델에 보내는 메시지 구성·추정 토큰·시스템 프롬프트, 실제 토큰 사용량/응답시간까지 그대로 표시
|
|
14
|
+
- **플러그인** — `.cdsa/plugins/` 에 JS 파일을 두면 **새 도구가 자동 등록**되어 모델이 사용
|
|
15
|
+
- **스킬** — `.cdsa/skills/` 에 마크다운을 두면 `/이름` 으로 부르는 **프롬프트 템플릿**
|
|
14
16
|
|
|
15
17
|
---
|
|
16
18
|
|
|
17
19
|
## 설치 / 실행
|
|
18
20
|
|
|
19
|
-
### npx (설치 없이 즉시)
|
|
20
|
-
|
|
21
21
|
```bash
|
|
22
|
-
#
|
|
23
|
-
|
|
24
|
-
npx . # API Key 없으면 자동 mock 모드
|
|
22
|
+
npx cdsa-harness # 설치 없이 즉시 (키 없으면 mock)
|
|
23
|
+
npm install -g cdsa-harness # 전역 설치 → 'cdsa-harness' / 'cdsa'
|
|
25
24
|
```
|
|
26
25
|
|
|
27
|
-
|
|
26
|
+
## 실제 AI 연결하기
|
|
28
27
|
|
|
28
|
+
가장 쉬운 길 — 실행 후 `/setup` 입력(대화형으로 제공자·키·모델 선택):
|
|
29
29
|
```bash
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
cdsa-harness # 어디서나 실행 (별칭: cdsa)
|
|
30
|
+
cdsa-harness
|
|
31
|
+
› /setup
|
|
33
32
|
```
|
|
34
33
|
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
또는 플래그/환경변수로:
|
|
37
35
|
```bash
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
cdsa-harness --provider openai --model gpt-4o-mini
|
|
37
|
+
cdsa-harness --provider anthropic --model claude-3-5-haiku-latest
|
|
38
|
+
|
|
39
|
+
# 키는 환경변수로도 자동 인식(파일에 저장 안 함)
|
|
40
|
+
export OPENAI_API_KEY=sk-...
|
|
41
|
+
export ANTHROPIC_API_KEY=sk-ant-...
|
|
42
|
+
export OPENROUTER_API_KEY=sk-or-...
|
|
40
43
|
```
|
|
41
44
|
|
|
42
|
-
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## 슬래시 명령
|
|
48
|
+
|
|
49
|
+
| 명령 | 설명 |
|
|
50
|
+
|------|------|
|
|
51
|
+
| `/setup` | 제공자·API 키·모델 대화형 연결 |
|
|
52
|
+
| `/provider <이름>` | openai · anthropic · openrouter · mock 전환 |
|
|
53
|
+
| `/model <이름>` | 모델 변경 |
|
|
54
|
+
| `/teach` | 교육 모드 켜기/끄기 |
|
|
55
|
+
| `/context` | 지금 모델에 보내는 컨텍스트 들여다보기 |
|
|
56
|
+
| `/reset` | 대화/컨텍스트 초기화 |
|
|
57
|
+
| `/config` | 현재 설정값 |
|
|
58
|
+
| `/quit` | 종료 (Ctrl+D) |
|
|
59
|
+
|
|
60
|
+
## 플래그
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
--provider <openai|anthropic|openrouter|mock>
|
|
64
|
+
--model <모델명>
|
|
65
|
+
--workspace <폴더경로>
|
|
66
|
+
--setup 대화형 연결 설정
|
|
67
|
+
--no-teach 교육 모드 끄고 간결 출력
|
|
68
|
+
--auto 승인 자동
|
|
69
|
+
```
|
|
43
70
|
|
|
44
71
|
---
|
|
45
72
|
|
|
46
|
-
##
|
|
73
|
+
## 🔌 플러그인 (추가 도구)
|
|
74
|
+
|
|
75
|
+
### 방법 A — npm 으로 설치 (권장)
|
|
76
|
+
|
|
77
|
+
`cdsa-harness-plugin-*` 이름의 패키지를 설치하면 **자동으로 발견·로드**됩니다.
|
|
47
78
|
|
|
48
79
|
```bash
|
|
49
|
-
cdsa-harness
|
|
50
|
-
|
|
51
|
-
cdsa-harness
|
|
52
|
-
|
|
80
|
+
cdsa-harness add cdsa-harness-plugin-git # = npm install 후 자동 로드
|
|
81
|
+
# 또는 직접: npm install cdsa-harness-plugin-git
|
|
82
|
+
cdsa-harness # 실행 → /plugins 에 자동 등록됨
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- cwd 의 `node_modules` 와 전역 설치 위치를 모두 탐색합니다.
|
|
86
|
+
- 이름 규칙과 무관하게 강제 로드하려면 `config.json` 의 `"plugins": ["패키지명"]` 에 추가.
|
|
87
|
+
- 플러그인 패키지는 default export 로 `플러그인 def` · `def 배열` · `{ tools:[...], skills:[...] }` 중 하나를 제공.
|
|
88
|
+
|
|
89
|
+
> **npm vs npx**: `npm install`(=설치, 보관) 으로 플러그인을 **추가**하고, `npx`(=설치 없이 실행) 또는 설치된 `cdsa-harness` 로 **실행**합니다.
|
|
90
|
+
|
|
91
|
+
### 방법 B — 로컬 파일 (실험용)
|
|
92
|
+
|
|
93
|
+
`.cdsa/plugins/` (작업 폴더) 또는 `~/.cdsa_harness/plugins/` 에 `.js`/`.mjs` 파일을 두면 자동 등록.
|
|
94
|
+
|
|
95
|
+
```js
|
|
96
|
+
// .cdsa/plugins/word_count.mjs
|
|
97
|
+
import fs from "node:fs";
|
|
98
|
+
import path from "node:path";
|
|
99
|
+
export default {
|
|
100
|
+
name: "word_count",
|
|
101
|
+
description: "텍스트 파일의 글자/줄/단어 수를 센다",
|
|
102
|
+
parameters: { type: "object", properties: { path: { type: "string" } }, required: ["path"] },
|
|
103
|
+
mutating: false, // true 면 실행 전 승인
|
|
104
|
+
async handler(args, ctx) { // ctx.workspace = 작업 폴더 절대경로
|
|
105
|
+
const text = fs.readFileSync(path.resolve(ctx.workspace, args.path), "utf8");
|
|
106
|
+
return `글자 ${text.length}, 줄 ${text.split("\n").length}`;
|
|
107
|
+
},
|
|
108
|
+
};
|
|
53
109
|
```
|
|
54
110
|
|
|
55
|
-
|
|
111
|
+
## 🎯 스킬 (프롬프트 템플릿)
|
|
56
112
|
|
|
113
|
+
`.cdsa/skills/` 또는 `~/.cdsa_harness/skills/` 에 마크다운을 두면 `/파일명` 으로 실행됩니다.
|
|
114
|
+
본문의 `$ARGUMENTS` 는 명령 뒤 텍스트로 치환됩니다. `/skills` 로 목록 확인.
|
|
115
|
+
|
|
116
|
+
```markdown
|
|
117
|
+
---
|
|
118
|
+
description: 파일을 읽고 3줄로 요약
|
|
57
119
|
---
|
|
120
|
+
$ARGUMENTS 파일을 read_file 로 읽고 핵심을 한국어 3줄로 요약해줘.
|
|
121
|
+
```
|
|
122
|
+
실행: `/summarize notes.txt`
|
|
58
123
|
|
|
59
124
|
## 설정 (config.json)
|
|
60
125
|
|
|
61
|
-
`~/.cdsa_harness/config.json`
|
|
126
|
+
`~/.cdsa_harness/config.json` (실행 폴더에 `config.json` 있으면 우선).
|
|
62
127
|
|
|
63
128
|
```json
|
|
64
129
|
{
|
|
65
130
|
"provider": "openai",
|
|
66
131
|
"api_key": "",
|
|
67
|
-
"model": "gpt-
|
|
132
|
+
"model": "gpt-4o-mini",
|
|
68
133
|
"workspace": "./workspace",
|
|
69
134
|
"approval_mode": "manual",
|
|
70
135
|
"allow_shell": false,
|
|
71
136
|
"max_steps": 8,
|
|
72
|
-
"temperature": 0.2
|
|
137
|
+
"temperature": 0.2,
|
|
138
|
+
"max_tokens": 1024,
|
|
139
|
+
"teach_mode": true
|
|
73
140
|
}
|
|
74
141
|
```
|
|
75
142
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
---
|
|
143
|
+
> `api_key` 가 비어 있으면 해당 provider 의 환경변수를 자동으로 찾습니다.
|
|
79
144
|
|
|
80
145
|
## 도구 & 안전장치
|
|
81
146
|
|
|
@@ -94,23 +159,20 @@ cdsa-harness --auto # 승인 자동
|
|
|
94
159
|
|
|
95
160
|
```
|
|
96
161
|
node-cli/
|
|
97
|
-
├── bin/cdsa-harness.js # npm/npx 진입점
|
|
162
|
+
├── bin/cdsa-harness.js # npm/npx 진입점
|
|
98
163
|
├── src/
|
|
99
|
-
│ ├── config.js # 설정
|
|
100
|
-
│ ├── llm.js # OpenAI/OpenRouter
|
|
101
|
-
│ ├── tools.js # 도구 + sandbox + diff
|
|
102
|
-
│ ├── loop.js # ⭐ Agent Loop
|
|
164
|
+
│ ├── config.js # 설정 + 환경변수 키 감지
|
|
165
|
+
│ ├── llm.js # OpenAI/Anthropic/OpenRouter + mock, 응답 정규화(토큰·지연)
|
|
166
|
+
│ ├── tools.js # 도구 + sandbox + diff
|
|
167
|
+
│ ├── loop.js # ⭐ Agent Loop + 교육용 이벤트(컨텍스트/되먹임)
|
|
103
168
|
│ ├── session.js # 세션 로그(JSONL)
|
|
104
|
-
│ ├── banner.js
|
|
105
|
-
│
|
|
106
|
-
│ └── cli.js # 터미널 REPL
|
|
107
|
-
├── workspace/ # 샘플 작업 폴더
|
|
169
|
+
│ ├── banner.js / ui.js # 배너 · ANSI/박스/diff 렌더
|
|
170
|
+
│ └── cli.js # REPL + 교육 모드 렌더 + /setup
|
|
108
171
|
└── test/core.test.js # node --test
|
|
109
172
|
```
|
|
110
173
|
|
|
111
174
|
## 테스트
|
|
112
175
|
|
|
113
176
|
```bash
|
|
114
|
-
cd node-cli
|
|
115
177
|
npm test # node --test
|
|
116
178
|
```
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cdsa-harness",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "AI 에이전트의 내부 동작을 단계별로 드러내는 교육용 터미널 하네스. OpenAI/Claude/OpenRouter + npm 으로 설치하는 플러그인(추가 도구)·스킬 확장.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"cdsa-harness": "bin/cdsa-harness.js",
|