[ contents ]
참고

Rasen 에이전트 계약

rasen CLI의 머신 읽기 가능 표면으로, src/에 대해 검증됨(작은 정상 감사, 2026-06-11). 아래의 모든 형태는 방출하는 코드에서 문서화됩니다.

1. 일반 규칙

  • 호출당 하나의 JSON 문서. --json 모드에서 stdout은 정확히 하나의 JSON 문서(2칸 예쁘게 인쇄)를 포함합니다. 인간 산문, 스피너 및 스토어 배너는 stderr로 이동합니다.
  • 스토어 배너. 인간 모드에서 스토어 선택 루트는 Using Rasen root: <id> (<path>)를 stderr로 인쇄합니다. JSON 모드에서는 절대 인쇄되지 않습니다.
  • 키 케이싱은 표면 종속적입니다(알려진 불일치 참조). 스토어/doctor/컨텍스트 페이로드는 snake_case 사용. 워크플로우 페이로드(status, instructions, new change, validate, list)는 camelCase 사용(포함된 root 객체 제외, 항상 store_id 사용).
  • 선택적 키는 생략되며 대부분의 페이로드에서 null이 아닙니다(예: root.store_id, member.path). 명시적 null을 사용하는 예외는 형태별로 호출됩니다(스토어 doctor git.*, 실패 페이로드).

2. 진단 봉투

하나의 봉투 형태는 모든 머신 읽기 가능 진단(StoreDiagnostic)으로 공유됩니다.

{
  "severity": "error" | "warning" | "info",
  "code": "snake_case_string",
  "message": "human sentence",
  "target": "dotted.surface (optional)",
  "fix": "one actionable sentence/command (optional)"
}

진단은 두 가지 위치에 나타납니다. 상태 배열(status: StoreDiagnostic[] 최상위 또는 항목별)은 상태 결과용이고, 발생된 오류는 명령 실패 시 단일 요소 status 배열로 변환됩니다.

3. 루트 선택 및 RootOutput

모든 루트 해석 명령(list, show, validate, status, instructions, instructions apply, new change, archive, doctor, context)은 하나의 우선순위로 하나의 Rasen 루트를 해석합니다.

  1. --store <id> → 등록된 스토어의 루트(source: "store").
  2. 그렇지 않으면 rasen/이 있는 가장 가까운 상위 항목. 계획 형태 → source: "nearest"(store: 포인터는 stderr 경고와 함께 무시됨). 유효한 store: 포인터가 있는 구성 전용 디렉토리 → 그 스토어, source: "declared".
  3. 가장 가까운 루트 없음 + 등록된 스토어 존재 → 오류 no_root_with_registered_stores.
  4. 루트 없음, 스토어 없음. 스캐폴딩 명령은 cwd를 source: "implicit"으로 취급합니다. 진단 명령(doctor, context)은 대신 no_openspec_root로 실패합니다 — 검사, 절대 스캐폴드하지 않습니다.

성공적인 JSON 페이로드는 루트를 포함합니다.

"root": { "path": "/abs/path", "source": "store" | "declared" | "nearest" | "implicit", "store_id": "id (only when store-selected)" }

루트 실패 계약: JSON 모드에서 해석 실패는 { ...commandNullShape, "status": [diagnostic] }을 stdout에 인쇄하고 1로 종료합니다.

4. 명령 JSON 형태

4.1 list --json

{ "changes": [ { "name", "completedTasks", "totalTasks", "lastModified", "status": "no-tasks"|"complete"|"in-progress" } ], "root": RootOutput } — 변경당 status가 여기서 문자열 열거형입니다. --specs: { "specs": [ { "id", "requirementCount" } ], "root" }.

4.2 show <item> --json

변경: { "id", "title", "deltaCount", "deltas": [...], "root" }. 스펙: { "id", "title", "overview", "requirementCount", "requirements": [...], "metadata": { "version", "format", "sourcePath"? }, "root" }.

4.3 validate --json

{ "items": [ { "id", "type": "change"|"spec", "valid", "issues": [ { "level", "path", "message", "line"?, "column"? } ], "durationMs" } ], "summary": { "totals": {items,passed,failed}, "byType": {...} }, "version": "1.0", "root" }. 모든 항목이 실패하면 1로 종료합니다.

4.4 status --json

{ "changeName", "schemaName", "planningHome"?: { "kind", "root", "changesDir", "defaultSchema" }, "changeRoot", "artifactPaths": { "<id>": {outputPath, resolvedOutputPath, existingOutputPaths} }, "nextSteps": ["..."], "actionContext": { "mode": "repo-local", "sourceOfTruth": "repo", "planningArtifacts", "linkedContext", "allowedEditRoots", "requiresAffectedAreaSelection", "constraints" }, "isComplete", "applyRequires", "artifacts": [ {id, outputPath, status: "done"|"ready"|"blocked", missingDeps?} ], "root" }. 활성 변경 없음: { "changes": [], "message", "root" }, 1로 종료합니다.

4.5 instructions <artifact> --json

{ "changeName", "artifactId", "schemaName", "changeDir", "planningHome"?, "outputPath", "resolvedOutputPath", "existingOutputPaths", "description", "instruction"?, "context"?, "rules"?, "references"?: ReferenceIndexEntry[], "template", "dependencies": [{id,done,path,description}], "unlocks", "root" }.

ReferenceIndexEntry: { "store_id", "root"?, "specs"?: [{id,summary}], "fetch"?, "status": [] } — 해석된 항목은 root/specs/fetch를 포함합니다. 해석되지 않은 항목은 store_id + 경고 상태를 포함합니다. 색인은 50KB(reference_index_truncated)로 제한됩니다.

4.6 instructions apply --json

{ "changeName", "changeDir", "schemaName", "contextFiles": { "<artifactId>": ["/abs", ...] }, "progress": {total,complete,remaining}, "tasks": [{id,description,done}], "state": "blocked"|"all_done"|"ready", "missingArtifacts"?, "instruction", "references"?, "root" }.

4.7 new change <name> --json

성공: { "change": { "id", "path", "metadataPath", "schema" }, "root" }. 실패: { "change": null, "status": [d] }, 1로 종료합니다.

4.8 archive <name> --json

성공: { "archive": { "change", "archivedAs": "YYYY-MM-DD-name", "path", "specsUpdated", "totals"? }, "root" }. 실패: { "archive": null, "root"?, "status": [d] }, 1로 종료합니다. JSON 모드는 엄격히 비대화형입니다. 모든 프롬프트 지점이 archive_* 코드가 됩니다.

4.9 doctor --json

{ "root": { "path", "source", "store_id"?, "healthy", "status": [] }, "store": { "id", "metadata": {present,valid,remote?}, "origin_url"?, "status": [] } | null, "references": [...], "status": [] }. 모든 심각도의 상태 결과는 0으로 종료합니다. 실패 페이로드: { "root": null, "store": null, "references": [], "status": [d] }, 1로 종료합니다.

4.10 context --json

{ "root": { "path", "source", "store_id"?, "role": "openspec_root" }, "members": [ { "role": "referenced_store", "id", "path"?, "remote"?, "fetch"?, "status": [] } ], "status": [] }. 사용 가능 = 경로 존재 및 상태 비어있음. --code-workspace <path>{folders:[{name,path}]} 작성(사용 가능한 참조 스토어만, ref: 접두사). JSON 모드에서 쓰기는 인쇄 전에 실행되므로 stdout은 쓰기 실패 시에도 정확히 하나의 문서를 보유합니다. 실패: { "root": null, "members": [], "status": [d] }, 1로 종료합니다.

4.11 store ... --json

setup/register: { "store": {id, root, metadata_path?}, "registry": {path, registered, already_registered}, "git": {is_repository, initialized, committed}, "created_files": [], "status": [] }. unregister/remove: { "store", "registry": {path, removed}, "files": {deleted, deleted_path, left_on_disk}, "status": [] }. list: { "stores": [{id, root}], "status": [] }. doctor: { "stores": [ { id, root, metadata_path?, openspec_root: {...healthy, status}, metadata: {present, valid, id?, remote}, git: {is_repository, has_commits, has_uncommitted_changes, has_remote, origin_url}, status } ], "status": [] } (null = 알 수 없음/프로브되지 않음). 상태 결과는 0으로 종료합니다. 실패는 일치하는 null 형태와 함께 1로 종료합니다. 프롬프트 취소는 130으로 종료합니다.

4.12 schemas --json / templates --json

schemas: 단순 배열 [ {name, description, artifacts, source} ]. templates: 키 지정 객체 { "<artifactId>": {path, source} }. 둘 다 cwd 기반, 루트/상태 키 없음.

5. 종료 코드 계약

상황 종료 Stdout
성공, 상태 결과 포함(doctor/context/store doctor) 0 페이로드
--json 모드의 명령 실패 1 status: [d] 및 명령의 null 형태가 있는 하나의 JSON 문서
실패 항목이 있는 validate 1 전체 보고서
프롬프트 취소(스토어 그룹, 인간 모드) 130 stderr만

6. 진단 코드 카탈로그

해석

no_openspec_root, no_root_with_registered_stores, no_registered_stores, unknown_store, store_identity_mismatch, unhealthy_store_root, store_path_not_supported, invalid_store_pointer, initiative_option_removed, areas_option_removed. 통과: invalid_store_id, invalid_store_registry, invalid_store_metadata.

Rasen 루트 상태(오류, 수정 없음)

openspec_store_root_missing, openspec_store_root_not_directory, openspec_root_missing, openspec_root_not_directory, openspec_config_missing, openspec_config_not_file, openspec_specs_not_directory, openspec_changes_not_directory, openspec_archive_not_directory. (specs/changes/archive는 선택적 디렉토리 — 경로에 비디렉토리가 존재할 때만 실패하고, 부재할 때는 아님.)

스토어 레지스트리/식별/상태

invalid_store_id, invalid_store_registry, invalid_store_metadata, store_registry_busy, store_not_found, no_store_registry, store_registry_changed, store_metadata_missing, store_metadata_id_mismatch, store_metadata_invalid, store_id_conflict, store_path_conflict, store_already_registered(정보).

스토어 설정/등록/제거

store_setup_id_required, store_setup_path_required, store_setup_path_not_directory, store_setup_inside_git_repo, store_setup_non_empty_directory, store_setup_cancelled, store_path_required, store_path_missing, store_path_not_directory, store_register_root_unhealthy, store_register_identity_confirmation_required, store_register_cancelled, store_remote_empty, store_remote_requires_hand_edit, store_remove_confirmation_required, store_remove_cancelled, store_remove_path_not_directory, store_remove_metadata_missing, store_root_missing(제거 시 경고, doctor에서 오류), store_root_not_directory.

스토어 git

store_git_init_failed, store_git_identity_missing, store_git_commit_failed, store_git_no_commits(경고), store_clone_fragile_directories(경고), store_remote_divergence(정보, doctor).

참조(경고)

reference_invalid_id, reference_registry_unreadable, reference_unresolved, reference_root_unhealthy, reference_index_truncated.

관계(경고; doctor; 컨텍스트는 레지스트리 하나만 유지)

relationship_registry_unreadable, root_pointer_ignored, root_pointer_invalid, pointer_declarations_inert.

보관(JSON 모드)

archive_change_name_required, archive_change_not_found, archive_validation_failed, archive_confirmation_required, archive_tasks_incomplete, archive_spec_update_failed, archive_spec_validation_failed, archive_target_exists, archive_error.

컨텍스트 쓰기

context_file_exists, context_output_dir_missing.

폴백

doctor_failed, context_failed, store_error, change_error, archive_error.

알려진 불일치

작은 정상 감사로 기록됨. 게시된 키 이름 바꾸기는 이 릴리스 이후로 연기된 제품 결정입니다.

  1. --json 모드에서 몇 가지 실패 경로는 JSON 문서 없이 stderr만 인쇄했습니다. 작은 정상 gauntlet 반올림에서 수정됨. show/validate 알 수 없음 및 모호한 항목이 {status:[{code: unknown_item | ambiguous_item, ...}]}를 방출합니다. status/instructions/list/show/validate의 발생된 오류는 JSON 인식 실패 도우미를 통해 라우팅됩니다(명령의 null 형태 + status). store <unknown subcommand> --json{status:[{code: unknown_store_subcommand}]}를 방출합니다. list는 해석 실패 시 {changes|specs: [], root: null} null 형태를 수행합니다.
  2. store_root_missing은 두 가지 심각도로 방출됩니다(제거에서 경고, 스토어 doctor에서 오류) — 컨텍스트 종속적, 위에 문서화됨.
  3. snake_case(스토어 계열) vs camelCase(워크플로우 계열) 키 케이싱. root.store_id는 모든 곳에서 snake_case입니다.
  4. src에 네 개의 평행 봉투 유형 선언이 존재합니다. 보관 진단은 절대 target을 수행하지 않습니다.
  5. list --json은 변경당 문자열 열거형으로 status 키를 재사용합니다.
  6. validate 출력만 version 필드를 수행합니다.
  7. schemas/templates는 루트 선택을 무시합니다(cwd 기반, --store 없음).
  8. 더 이상 사용되지 않는 명사 형태(change/spec 부명령)는 root/status 없이 포장되지 않은 페이로드를 방출합니다.