agentic-domain-document 0.6.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.
Files changed (106) hide show
  1. package/.tbls.yml +201 -0
  2. package/CHANGELOG.md +68 -0
  3. package/README.md +313 -0
  4. package/agent/agent.manifest.json +8 -0
  5. package/agent/capabilities/document-authoring.json +21 -0
  6. package/agent/capabilities/document-block.json +22 -0
  7. package/agent/capabilities/document-toc.json +21 -0
  8. package/agent/capabilities/document-validation.json +21 -0
  9. package/agent/examples/document-quality-examples.md +153 -0
  10. package/agent/examples/examples.md +172 -0
  11. package/agent/guides/10-document-authoring-guide.md +28 -0
  12. package/agent/guides/20-domain-boundary-guide.md +41 -0
  13. package/agent/guides/30-authoring-policy-guide.md +40 -0
  14. package/agent/guides/40-toc-authoring-guide.md +73 -0
  15. package/agent/guides/50-content-block-guide.md +57 -0
  16. package/agent/guides/51-paragraph-authoring-guide.md +68 -0
  17. package/agent/guides/52-table-authoring-guide.md +73 -0
  18. package/agent/guides/53-diagram-figure-authoring-guide.md +75 -0
  19. package/agent/guides/70-korean-writing-style-guide.md +65 -0
  20. package/agent/instructions/00-runtime-behavior.md +17 -0
  21. package/agent/instructions/10-scope-and-boundary.md +27 -0
  22. package/agent/instructions/20-task-procedures.md +69 -0
  23. package/agent/instructions/30-must-and-must-not.md +34 -0
  24. package/agent/resource-index.json +185 -0
  25. package/agent/resource-selection.json +205 -0
  26. package/agent/routing.json +34 -0
  27. package/agent/sources/reference-mapping.md +53 -0
  28. package/agent/validation/document-validation-rules.md +73 -0
  29. package/dist/agent/document-agent-contribution.d.ts +15 -0
  30. package/dist/agent/document-agent-contribution.d.ts.map +1 -0
  31. package/dist/agent/document-agent-contribution.js +39 -0
  32. package/dist/agent/document-agent-contribution.js.map +1 -0
  33. package/dist/agent/index.d.ts +2 -0
  34. package/dist/agent/index.d.ts.map +1 -0
  35. package/dist/agent/index.js +2 -0
  36. package/dist/agent/index.js.map +1 -0
  37. package/dist/database.d.ts +8 -0
  38. package/dist/database.d.ts.map +1 -0
  39. package/dist/database.js +76 -0
  40. package/dist/database.js.map +1 -0
  41. package/dist/index.d.ts +15 -0
  42. package/dist/index.d.ts.map +1 -0
  43. package/dist/index.js +14 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/markdown-importer.d.ts +14 -0
  46. package/dist/markdown-importer.d.ts.map +1 -0
  47. package/dist/markdown-importer.js +386 -0
  48. package/dist/markdown-importer.js.map +1 -0
  49. package/dist/reader.d.ts +17 -0
  50. package/dist/reader.d.ts.map +1 -0
  51. package/dist/reader.js +332 -0
  52. package/dist/reader.js.map +1 -0
  53. package/dist/repositories.d.ts +118 -0
  54. package/dist/repositories.d.ts.map +1 -0
  55. package/dist/repositories.js +388 -0
  56. package/dist/repositories.js.map +1 -0
  57. package/dist/service.d.ts +35 -0
  58. package/dist/service.d.ts.map +1 -0
  59. package/dist/service.js +327 -0
  60. package/dist/service.js.map +1 -0
  61. package/dist/types.d.ts +276 -0
  62. package/dist/types.d.ts.map +1 -0
  63. package/dist/types.js +2 -0
  64. package/dist/types.js.map +1 -0
  65. package/dist/validators.d.ts +4 -0
  66. package/dist/validators.d.ts.map +1 -0
  67. package/dist/validators.js +255 -0
  68. package/dist/validators.js.map +1 -0
  69. package/docs/build.md +55 -0
  70. package/docs/configuration.md +34 -0
  71. package/docs/delivery.md +50 -0
  72. package/docs/operations.md +50 -0
  73. package/docs/publishing.md +69 -0
  74. package/docs/schema/generated/README.md +30 -0
  75. package/docs/schema/generated/document_annotations.md +119 -0
  76. package/docs/schema/generated/document_annotations.svg +60 -0
  77. package/docs/schema/generated/document_blocks.md +97 -0
  78. package/docs/schema/generated/document_blocks.svg +60 -0
  79. package/docs/schema/generated/document_change_events.md +135 -0
  80. package/docs/schema/generated/document_change_events.svg +88 -0
  81. package/docs/schema/generated/document_code_groups.md +70 -0
  82. package/docs/schema/generated/document_code_groups.svg +52 -0
  83. package/docs/schema/generated/document_codes.md +88 -0
  84. package/docs/schema/generated/document_codes.svg +52 -0
  85. package/docs/schema/generated/document_contents.md +87 -0
  86. package/docs/schema/generated/document_contents.svg +116 -0
  87. package/docs/schema/generated/document_documents.md +126 -0
  88. package/docs/schema/generated/document_documents.svg +222 -0
  89. package/docs/schema/generated/document_node_taxonomies.md +84 -0
  90. package/docs/schema/generated/document_node_taxonomies.svg +80 -0
  91. package/docs/schema/generated/document_node_taxonomy_levels.md +91 -0
  92. package/docs/schema/generated/document_node_taxonomy_levels.svg +52 -0
  93. package/docs/schema/generated/document_nodes.md +120 -0
  94. package/docs/schema/generated/document_nodes.svg +98 -0
  95. package/docs/schema/generated/document_revisions.md +107 -0
  96. package/docs/schema/generated/document_revisions.svg +116 -0
  97. package/docs/schema/generated/document_versions.md +126 -0
  98. package/docs/schema/generated/document_versions.svg +88 -0
  99. package/docs/schema/generated/schema.json +2534 -0
  100. package/docs/schema/generated/schema.mmd +170 -0
  101. package/docs/schema/generated/schema.svg +331 -0
  102. package/docs/schema/migrations.md +40 -0
  103. package/docs/usage.md +332 -0
  104. package/docs/validation-rules.md +69 -0
  105. package/package.json +30 -0
  106. package/src/database/migrations/0001_document_base.sql +753 -0
package/.tbls.yml ADDED
@@ -0,0 +1,201 @@
1
+ name: agentic-domain-document
2
+ desc: Agentic Platform document domain database.
3
+
4
+ dsn: ${AGENTIC_DOMAIN_DOCUMENT_SCHEMA_DSN}
5
+ docPath: ${AGENTIC_DOMAIN_DOCUMENT_SCHEMA_DOC_PATH}
6
+
7
+ format:
8
+ adjust: true
9
+ sort: false
10
+ number: false
11
+ hideColumnsWithoutValues: true
12
+
13
+ er:
14
+ skip: false
15
+ format: svg
16
+ comment: true
17
+ hideDef: true
18
+ showColumnTypes:
19
+ related: true
20
+ primary: true
21
+ distance: 1
22
+
23
+ include:
24
+ - document_*
25
+
26
+ comments:
27
+ - table: document_code_groups
28
+ tableComment: 코드 그룹을 정의한다.
29
+ columnComments:
30
+ code_group_code: 코드 그룹 식별자
31
+ code_group_name: 코드 그룹 한글명
32
+ description: 코드 그룹 설명
33
+ sort_order: 표시 정렬 순서
34
+ is_active: 활성 여부
35
+ created_at: 생성 시각
36
+ updated_at: 수정 시각
37
+
38
+ - table: document_codes
39
+ tableComment: 코드 그룹별 코드 값을 정의한다.
40
+ columnComments:
41
+ code_group_code: 코드 그룹 식별자
42
+ code: 코드 값
43
+ code_name: 코드 한글명
44
+ description: 코드 설명
45
+ sort_order: 표시 정렬 순서
46
+ is_active: 활성 여부
47
+ metadata_json: 확장 메타데이터
48
+ created_at: 생성 시각
49
+ updated_at: 수정 시각
50
+
51
+ - table: document_node_taxonomies
52
+ tableComment: 문서 유형별 node level 해석 정책을 정의한다.
53
+ columnComments:
54
+ taxonomy_id: taxonomy 식별자
55
+ taxonomy_code: taxonomy 코드
56
+ taxonomy_name: taxonomy 이름
57
+ document_type_code: 문서 유형 코드
58
+ default_toc_level_limit: 기본 TOC 포함 level
59
+ description: 설명
60
+ is_active: 활성 여부
61
+ created_at: 생성 시각
62
+ updated_at: 수정 시각
63
+
64
+ - table: document_node_taxonomy_levels
65
+ tableComment: taxonomy별 node level 라벨, 번호 정책, counter scope를 정의한다.
66
+ columnComments:
67
+ taxonomy_level_id: taxonomy level 식별자
68
+ taxonomy_id: taxonomy 식별자
69
+ node_level: node level
70
+ node_label_code: node label 코드
71
+ numbering_policy_code: 번호 정책 코드
72
+ counter_scope_code: 번호 카운터 범위 코드
73
+ sort_order: 표시 정렬 순서
74
+ created_at: 생성 시각
75
+ updated_at: 수정 시각
76
+
77
+ - table: document_documents
78
+ tableComment: 문서 단위 메타데이터, 작성자, taxonomy, 상태를 관리한다.
79
+ columnComments:
80
+ document_id: 문서 식별자
81
+ document_type_code: 문서 유형 코드
82
+ taxonomy_id: 적용 taxonomy 식별자
83
+ title: 문서 제목
84
+ source_document_id: 파생 원본 문서 식별자
85
+ version_label: 표시 버전
86
+ author_type_code: 작성자 유형
87
+ author_id: 작성자 식별자
88
+ author_name: 작성자 표시명
89
+ status_code: 문서 상태
90
+ toc_level_limit: TOC로 취급할 level limit
91
+ published_at: published 상태 전환 시각
92
+ created_at: 생성 시각
93
+ updated_at: 수정 시각
94
+ metadata_json: 확장 메타데이터
95
+
96
+ - table: document_nodes
97
+ tableComment: 문서의 계층 node tree를 관리한다.
98
+ columnComments:
99
+ node_id: 노드 식별자
100
+ document_id: 소속 문서 식별자
101
+ parent_node_id: 상위 노드 식별자
102
+ node_level: node level
103
+ node_role_code: 노드 역할 코드
104
+ title: 노드 제목
105
+ toc_visibility: TOC 표시 정책
106
+ numbering_policy_code: 번호 정책 코드
107
+ numbering_override: 수동 번호 override
108
+ sort_order: 형제 노드 내 정렬 순서
109
+ created_at: 생성 시각
110
+ updated_at: 수정 시각
111
+ metadata_json: 확장 메타데이터
112
+
113
+ - table: document_contents
114
+ tableComment: 특정 document node에 붙는 block collection을 관리한다.
115
+ columnComments:
116
+ content_id: content 식별자
117
+ document_id: 소속 문서 식별자
118
+ node_id: 소속 노드 식별자
119
+ created_at: 생성 시각
120
+ updated_at: 수정 시각
121
+ metadata_json: 확장 메타데이터
122
+
123
+ - table: document_blocks
124
+ tableComment: 문서 본문 표현 block을 관리한다.
125
+ columnComments:
126
+ block_id: block 식별자
127
+ content_id: 소속 content 식별자
128
+ block_type_code: block 유형 코드
129
+ sort_order: content 안에서의 순서
130
+ content_text: 텍스트 중심 block 본문
131
+ content_json: 구조형 block payload
132
+ created_at: 생성 시각
133
+ updated_at: 수정 시각
134
+ metadata_json: 확장 메타데이터
135
+
136
+ - table: document_annotations
137
+ tableComment: 문서 본문 밖의 note annotation을 관리한다.
138
+ columnComments:
139
+ annotation_id: annotation 식별자
140
+ document_id: 소속 문서 식별자
141
+ target_type_code: annotation 대상 유형
142
+ target_id: annotation 대상 식별자
143
+ annotation_type_code: annotation 유형
144
+ status_code: annotation 상태
145
+ note_text: note 내용
146
+ author_type_code: 작성자 유형
147
+ author_id: 작성자 식별자
148
+ author_name: 작성자 표시명
149
+ resolved_at: 해결 시각
150
+ created_at: 생성 시각
151
+ updated_at: 수정 시각
152
+ metadata_json: 확장 메타데이터
153
+
154
+ - table: document_revisions
155
+ tableComment: 하나 이상의 변경 이벤트를 묶는 의미 있는 변경 단위를 관리한다.
156
+ columnComments:
157
+ revision_id: revision 식별자
158
+ document_id: 소속 문서 식별자
159
+ revision_no: 문서별 revision 순번
160
+ revision_title: revision 제목
161
+ revision_reason: revision 사유
162
+ document_status_code: revision 생성 당시 문서 상태
163
+ created_by_type_code: revision 생성자 유형
164
+ created_by_id: revision 생성자 식별자
165
+ created_by_name: revision 생성자 표시명
166
+ created_at: 생성 시각
167
+ metadata_json: revision 요약/확장 메타데이터
168
+
169
+ - table: document_change_events
170
+ tableComment: revision에 속하는 로그성 변경 이벤트를 관리한다.
171
+ columnComments:
172
+ event_id: event 식별자
173
+ revision_id: 소속 revision 식별자
174
+ document_id: 소속 문서 식별자
175
+ sequence_no: revision 안에서의 event 순서
176
+ target_type_code: 변경 대상 유형
177
+ target_id: 변경 대상 식별자
178
+ change_type_code: 변경 유형
179
+ change_reason: 개별 변경 사유
180
+ changed_by_type_code: 변경자 유형
181
+ changed_by_id: 변경자 식별자
182
+ changed_by_name: 변경자 표시명
183
+ changed_at: 변경 시각
184
+ metadata_json: 이벤트 메타데이터
185
+
186
+ - table: document_versions
187
+ tableComment: 검토/승인/배포 기준본 snapshot을 관리한다.
188
+ columnComments:
189
+ version_id: version 식별자
190
+ document_id: 소속 문서 식별자
191
+ revision_id: 기준 revision 식별자
192
+ version_no: 문서별 version 순번
193
+ version_label: 표시 버전
194
+ snapshot_type_code: snapshot 유형
195
+ document_status_code: snapshot 당시 문서 상태
196
+ snapshot_json: 작은 snapshot 또는 manifest
197
+ checksum: snapshot checksum
198
+ created_by_type_code: 생성자 유형
199
+ created_by_id: 생성자 식별자
200
+ created_by_name: 생성자 표시명
201
+ created_at: 생성 시각
package/CHANGELOG.md ADDED
@@ -0,0 +1,68 @@
1
+ # Changelog
2
+
3
+ ## 0.6.0
4
+
5
+ - Adoc/Agentic Document 브랜딩 지시문과 routing keyword 추가
6
+ - `DocumentReader`와 `createDocumentReader` public API 추가
7
+ - `getDocumentAggregate`, `getDocumentTree`, `findBlocks`, `listDocuments`, `getLatestDocument` 조회 API 추가
8
+ - 기본 조회용 `toMarkdown` Adoc Markdown Projection 추가
9
+ - `DocumentMarkdownImporter`와 `createDocumentMarkdownImporter` public API 추가
10
+ - `importMarkdownDocument`, `importMarkdownChapter` 기반 Markdown import 추가
11
+ - Markdown Import에서 `표 N. 제목 - 요약` table caption binding 추가
12
+ - Markdown Import에서 image alt/visible `그림 N. 제목 - 요약` figure caption binding 및 중복 caption paragraph 제거 추가
13
+ - Adoc Markdown Projection에서 table, figure, diagram block의 기본 Markdown 복원 추가
14
+ - table, figure, diagram block payload validation 보강
15
+ - 참조 아키텍처 명세서 Markdown import dev-test 추가
16
+ - Agent 지시문에 wrapper 우선, 직접 SQL 제한, Markdown Projection 직접 수정 금지 기준 추가
17
+ - `agent/resource-selection.json` 추가
18
+ - Document Agent resource selection을 keyword 기반 최소 JSON rule로 제공
19
+ - Always resource, fallback baseline, TOC/Table/Diagram/Style/Validation/Traceability rule 추가
20
+ - Document Agent public export에 `documentResourceSelection`, `documentResourceSelectionRules` 추가
21
+ - Document Agent public export에 `selectDocumentAgentResources`, `assembleDocumentAgentContext` 추가
22
+ - runtime CLI 등록 표준 export인 `agentContribution` alias 추가
23
+ - revision/change event/version/annotation 일시의 UTC 저장 및 KST 표시 기준 문서화
24
+ - `agentic-capability-agent-client@0.4.0` 의존성 반영
25
+
26
+ ## 0.5.0
27
+
28
+ - Agent contribution 구조를 `instruction-set.json`에서 `resource-index.json`으로 전환
29
+ - Agent 리소스를 Instruction, Guide, Example, Validator Rule, Source Mapping 5종으로 분리
30
+ - `resourceGroups.order`로 리소스 분류 적용 순서를 가시화
31
+ - `agent/instructions/`를 작동형 지시문 중심으로 재작성
32
+ - 기존 상세 작성 기준을 `agent/guides/`로 분리
33
+ - validation rule을 `agent/validation/document-validation-rules.md`로 분리
34
+ - Document Agent public export를 `documentResourceIndex`, `documentInstructionResources`, `documentGuideResources`, `documentExampleResources`, `documentValidationRuleResources`, `documentSourceResources`로 변경
35
+ - `agentic-capability-agent-client@0.3.0` 의존성 반영
36
+
37
+ ## 0.4.0
38
+
39
+ - Document Agent 지시문을 참조 프로젝트 분석 결과 기반으로 대폭 보강
40
+ - output 순수성, source 우선순위, 근거 없는 확정 금지, 본문 작성과 기준 수정 분리 정책 추가
41
+ - Document/Content/Typed Block/Annotation/Revision/Render/Artifact 경계 설명 강화
42
+ - 한국어 문체, 외래어, 용어, 금지 표현, 문장 개선 예시 추가
43
+ - TOC taxonomy, level limit, visibility, numbering policy, heading 경계 기준 보강
44
+ - Paragraph/Table/Diagram/Figure 작성 기준과 schemaRef/source/rendered artifact 분리 기준 보강
45
+ - Document validation checklist를 document, TOC, content/block, style, table/diagram, revision/annotation, source mapping 기준으로 세분화
46
+ - 실제 참조 프로젝트 기반 좋은 예/나쁜 예/개선 예 추가
47
+ - Document Agent source mapping을 상세 참조 파일 기준으로 갱신
48
+
49
+ ## 0.3.0
50
+
51
+ - `agentic-capability-agent-client` 기반 Document Agent contribution 추가
52
+ - Document Agent manifest, capability, routing keyword를 표준 `agent/` 리소스로 외부화
53
+ - Document 작성 지시문을 `agent/instructions/*.md` 원천 파일과 domain/policy/style/structure/block/validation/example 계층으로 구조화
54
+ - `agent/sources/reference-mapping.md` 기반 source mapping 초안 추가
55
+ - TypeScript agent 구현을 resource loader/export 중심으로 축소
56
+ - Document package public export에 `documentAgentContribution` 추가
57
+ - dev-test에 Document Agent contribution 검증 추가
58
+
59
+ ## 0.1.0
60
+
61
+ - `agentic-domain-document` 패키지 skeleton 추가
62
+ - Document domain의 책임 범위, 제외 범위, DB 명명 기준 문서화
63
+ - Continuous Publish/Delivery 기반 문서 추가
64
+ - Iteration 0 기준 build/typecheck/pack dry-run 검증 대상으로 구성
65
+ - Document DB migration baseline 추가
66
+ - `document_*` schema docs 생성 기준 추가
67
+ - `createDocumentService` 기반 Repository/Service/Validator API 추가
68
+ - Document 생성, node/content/block 추가, TOC 조회, validation, review/approve/publish, draft 복제 dev-test 추가
package/README.md ADDED
@@ -0,0 +1,313 @@
1
+ # agentic-domain-document
2
+
3
+ `agentic-domain-document`는 Agentic Platform의 문서 도메인 패키지입니다.
4
+
5
+ 이 패키지는 `Document`, `TOC Node`, `Content`, `Typed Block`을 관리하기 위한 하위 도메인 패키지입니다. `artifact-standard`, `artifact`, `methodology`, `knowledge` 계열 패키지는 이 패키지를 참조해서 문서 구조와 본문 block을 사용할 수 있습니다.
6
+
7
+ `Adoc`은 이 패키지가 관리하는 Agentic Document의 공식 약칭입니다. Adoc은 Document/Node/Content/Block 기반으로 저장되며, `Adoc Tree`와 `Adoc Markdown Projection`으로 조회할 수 있습니다.
8
+
9
+ ## 현재 범위
10
+
11
+ Iteration 1에서는 문서 도메인 SQLite schema baseline과 최소 Repository/Service/Validator API를 제공합니다.
12
+
13
+ | 구분 | 상태 |
14
+ | --- | --- |
15
+ | 패키지 skeleton | 포함 |
16
+ | 기본 문서 | 포함 |
17
+ | build/typecheck | 포함 |
18
+ | pack dry-run | 포함 |
19
+ | Document DB migration | 포함 |
20
+ | Repository/Service/Validator | 포함 |
21
+ | Document Reader | 포함 |
22
+ | Adoc Markdown Projection | 기본 조회용 projection 포함, table/figure/diagram 복원 포함 |
23
+ | Markdown Import | 기본 전체 문서/챕터 import 포함, table/figure caption binding 포함 |
24
+ | Public wrapper API | 포함 |
25
+ | Document Agent contribution | 포함 |
26
+ | CLI | 1차 구현 제외, 전체 lifecycle 검토 대상 |
27
+ | Adapter | 1차 구현 제외, 전체 lifecycle 검토 대상 |
28
+
29
+ ## 도메인 책임
30
+
31
+ ```text
32
+ agentic-domain-document
33
+ - Document
34
+ - TOC Node
35
+ - Content
36
+ - Typed Block
37
+ - Document validation
38
+ - Document fixture
39
+ - Document repository/service
40
+ - Document reader/query
41
+ - Markdown import
42
+ - Document migration/schema docs
43
+ - Document Agent manifest/instruction contribution
44
+ ```
45
+
46
+ ## 제외 범위
47
+
48
+ | 제외 항목 | 담당 후보 |
49
+ | --- | --- |
50
+ | Artifact | `agentic-domain-artifact` |
51
+ | Artifact Standard Package | `agentic-domain-artifact-standard` |
52
+ | Knowledge | `agentic-domain-knowledge` |
53
+ | Methodology | `agentic-domain-methodology` |
54
+ | Render | `agentic-support-render` 후보 |
55
+ | Agent Routing | runtime/router 계열 |
56
+
57
+ ## DB 명명 기준
58
+
59
+ | 구분 | 기준 |
60
+ | --- | --- |
61
+ | logical schema | `document` |
62
+ | SQLite table prefix | `document_` |
63
+ | PostgreSQL mapping | `document.*`, 단 실제 적용은 향후 별도 프로세스 |
64
+
65
+ 초기 테이블:
66
+
67
+ ```text
68
+ document_code_groups
69
+ document_codes
70
+ document_node_taxonomies
71
+ document_node_taxonomy_levels
72
+ document_documents
73
+ document_nodes
74
+ document_contents
75
+ document_blocks
76
+ document_annotations
77
+ document_revisions
78
+ document_change_events
79
+ document_versions
80
+ ```
81
+
82
+ ## 개발 검증
83
+
84
+ ```bash
85
+ npm run build --workspace agentic-domain-document
86
+ npm run typecheck --workspace agentic-domain-document
87
+ npm run dev:test:agentic-domain-document
88
+ npm pack --workspace agentic-domain-document --dry-run --cache /private/tmp/agentic-npm-cache
89
+ ```
90
+
91
+ ## 기본 API 예시
92
+
93
+ ```ts
94
+ import { createDocumentService } from "agentic-domain-document";
95
+
96
+ const service = createDocumentService({
97
+ databasePath: ".agentic/platform.sqlite"
98
+ });
99
+
100
+ try {
101
+ const document = service.createDocument({
102
+ title: "요구사항 정의서",
103
+ documentTypeCode: "default",
104
+ taxonomyCode: "default"
105
+ });
106
+
107
+ const chapter = service.createNode({
108
+ documentId: document.documentId,
109
+ nodeLevel: 1,
110
+ title: "개요"
111
+ });
112
+
113
+ const content = service.ensureContent(chapter.nodeId);
114
+ service.addBlock({
115
+ contentId: content.contentId,
116
+ blockTypeCode: "paragraph",
117
+ contentText: "문서 본문을 작성합니다."
118
+ });
119
+
120
+ const validation = service.validateDocument(document.documentId);
121
+ console.log(validation.valid);
122
+ } finally {
123
+ service.close();
124
+ }
125
+ ```
126
+
127
+ ## Adoc 조회 API 예시
128
+
129
+ Adoc 조회는 직접 SQL보다 `DocumentReader` public API를 우선 사용합니다.
130
+
131
+ ```ts
132
+ import { createDocumentReader } from "agentic-domain-document";
133
+
134
+ const reader = createDocumentReader({
135
+ databasePath: ".agentic/platform.sqlite"
136
+ });
137
+
138
+ try {
139
+ const latest = reader.getLatestDocument({
140
+ documentTypeCode: "architecture_specification"
141
+ });
142
+
143
+ if (latest !== undefined) {
144
+ const tree = reader.getDocumentTree(latest.documentId);
145
+ const blocks = reader.findBlocks(latest.documentId, {
146
+ contains: "Contract API"
147
+ });
148
+ const markdown = reader.toMarkdown(latest.documentId);
149
+
150
+ console.log(tree.length);
151
+ console.log(blocks.length);
152
+ console.log(markdown);
153
+ }
154
+ } finally {
155
+ reader.close();
156
+ }
157
+ ```
158
+
159
+ `toMarkdown()`은 본격 렌더링 엔진이 아니라 Adoc을 사람이 읽기 쉽게 보여주기 위한 기본 Markdown Projection입니다. Projection은 조회용 파생물이며 원천이 아닙니다. Markdown 파일 저장, checksum, stale 검증, PDF/PPTX/HTML 렌더링은 후속 `agentic-capability-render` 책임입니다.
160
+
161
+ 기본 Markdown Projection은 `paragraph`, `quote`, `list`, `code`, `table`, `figure`, `diagram` block을 Markdown으로 복원합니다. `table`은 `columns`와 `rows`를 Markdown table로 출력하고, `figure`는 image reference와 visible caption으로 출력하며, `diagram`은 mermaid/plantuml source block을 fenced code block으로 출력합니다.
162
+
163
+ ## Adoc Markdown Import 예시
164
+
165
+ Adoc 작성의 1차 import 대상은 Markdown입니다. 전체 문서 생성과 기존 문서에 대한 챕터 append를 지원합니다.
166
+
167
+ ```ts
168
+ import { createDocumentMarkdownImporter } from "agentic-domain-document";
169
+
170
+ const importer = createDocumentMarkdownImporter({
171
+ databasePath: ".agentic/platform.sqlite"
172
+ });
173
+
174
+ try {
175
+ const document = importer.importMarkdownDocument({
176
+ title: "아키텍처 명세서",
177
+ documentTypeCode: "architecture_specification",
178
+ taxonomyCode: "architecture_specification",
179
+ markdown,
180
+ sourcePath: "chapters/chapter-01.md",
181
+ policy: {
182
+ validateAfterImport: true
183
+ }
184
+ });
185
+
186
+ importer.importMarkdownChapter({
187
+ documentId: document.document.documentId,
188
+ markdown: chapterMarkdown,
189
+ sourcePath: "chapters/chapter-02.md",
190
+ policy: {
191
+ validateAfterImport: true
192
+ }
193
+ });
194
+ } finally {
195
+ importer.close();
196
+ }
197
+ ```
198
+
199
+ Markdown Import는 draft Adoc 생성과 챕터 append를 위한 작성 진입점입니다. PDF/PPTX/HTML import, BlockFlow YAML import, merge/reconcile은 1차 범위에서 제외합니다.
200
+
201
+ Markdown Import는 다음 기본 구조화를 수행합니다.
202
+
203
+ ```text
204
+ - Markdown heading -> Document Node
205
+ - paragraph, quote, list, code -> Typed Block
206
+ - Markdown table -> table block
207
+ - `표 N. 제목 - 요약` + table -> caption이 결합된 table block
208
+ - Markdown image -> figure block
209
+ - image alt와 visible `그림 N. 제목 - 요약` caption -> caption이 결합된 figure block
210
+ - mermaid/plantuml fenced code -> diagram block
211
+ ```
212
+
213
+ ## Document Agent Contribution
214
+
215
+ `agentic-domain-document`는 문서 작성 agent가 사용할 manifest와 resource index를 제공합니다. 이 contribution은 `agentic-capability-agent-client`의 공통 계약을 따르며, runtime/router가 설치된 패키지의 agent 기여분을 일관되게 등록하고 선택할 수 있게 합니다.
216
+
217
+ Agent manifest, routing, capability, resource index, instruction, guide, example, validation rule, source mapping은 TypeScript inline 문자열이 아니라 package root의 `agent/` 리소스를 원천으로 관리합니다.
218
+
219
+ ```text
220
+ agentic-domain-document/
221
+ agent/
222
+ agent.manifest.json
223
+ routing.json
224
+ resource-index.json
225
+ resource-selection.json
226
+ capabilities/
227
+ document-authoring.json
228
+ document-block.json
229
+ document-toc.json
230
+ document-validation.json
231
+ instructions/
232
+ 00-runtime-behavior.md
233
+ 10-scope-and-boundary.md
234
+ 20-task-procedures.md
235
+ 30-must-and-must-not.md
236
+ guides/
237
+ 10-document-authoring-guide.md
238
+ 20-domain-boundary-guide.md
239
+ 30-authoring-policy-guide.md
240
+ 40-toc-authoring-guide.md
241
+ 50-content-block-guide.md
242
+ 51-paragraph-authoring-guide.md
243
+ 52-table-authoring-guide.md
244
+ 53-diagram-figure-authoring-guide.md
245
+ 70-korean-writing-style-guide.md
246
+ validation/
247
+ document-validation-rules.md
248
+ examples/
249
+ examples.md
250
+ document-quality-examples.md
251
+ sources/
252
+ reference-mapping.md
253
+ ```
254
+
255
+ ```ts
256
+ import { documentAgentContribution } from "agentic-domain-document";
257
+
258
+ console.log(documentAgentContribution.manifest.agentId);
259
+ console.log(documentAgentContribution.resourceIndex?.instructions[0].path);
260
+ ```
261
+
262
+ resource index는 다음 리소스를 구분해 제공합니다.
263
+
264
+ | 순서 | 구분 | 내용 |
265
+ | --- | --- |
266
+ | 1 | instructions | Agent가 반드시 따르는 작동 규칙 |
267
+ | 2 | guides | 작성 품질을 높이는 상세 기준 |
268
+ | 3 | examples | 좋은/나쁜 결과 예시와 payload 예시 |
269
+ | 4 | validationRules | 기계적으로 검증할 수 있는 기준 |
270
+ | 5 | sources | 규칙의 출처와 반영 근거 |
271
+
272
+ `resourceGroups.order`는 위 분류 간 적용 순서를 나타내고, 각 리소스의 `priority`는 같은 분류 안에서의 파일 적용 순서를 나타냅니다.
273
+
274
+ `resource-selection.json`은 사용자 요청에 따라 위 resource 중 어떤 묶음을 agent context에 포함할지 정의합니다. 예를 들어 “표 컬럼 헤더를 설계해줘” 요청은 공통 instruction, authoring guide, Korean writing guide, content block guide, table guide, quality example, validation rule을 함께 선택합니다.
275
+
276
+ ```ts
277
+ import {
278
+ assembleDocumentAgentContext,
279
+ documentAgentContribution,
280
+ documentResourceSelectionRules,
281
+ selectDocumentAgentResources
282
+ } from "agentic-domain-document";
283
+ import { selectAgentResources } from "agentic-capability-agent-client";
284
+
285
+ const bundle = selectAgentResources(documentAgentContribution, {
286
+ requestText: "표 컬럼 헤더를 설계해줘"
287
+ });
288
+
289
+ console.log(documentResourceSelectionRules.length);
290
+ console.log(bundle.bundleType);
291
+ console.log(bundle.resourceIds);
292
+
293
+ const documentBundle = selectDocumentAgentResources("표 컬럼 헤더를 설계해줘");
294
+ const context = assembleDocumentAgentContext("표 컬럼 헤더를 설계해줘");
295
+
296
+ console.log(documentBundle.bundleType);
297
+ console.log(context.contentText);
298
+ ```
299
+
300
+ Korean writing guide는 문체 요청에만 쓰는 부가 guide가 아니라 문서 작성, 수정, 검토의 baseline guide로 취급합니다. Source mapping은 평상시 작성 context에는 항상 포함하지 않고, 출처 확인이나 규칙 보완 요청에서 선택합니다.
301
+
302
+ ## 문서
303
+
304
+ | 문서 | 내용 |
305
+ | --- | --- |
306
+ | [docs/usage.md](./docs/usage.md) | 사용 기준 |
307
+ | [docs/configuration.md](./docs/configuration.md) | 설정 책임 |
308
+ | [docs/build.md](./docs/build.md) | 구축 담당자 빌드/검증 |
309
+ | [docs/publishing.md](./docs/publishing.md) | publish 절차 |
310
+ | [docs/delivery.md](./docs/delivery.md) | 운영환경 전달 기준 |
311
+ | [docs/operations.md](./docs/operations.md) | 운영환경 설치/검증 |
312
+ | [docs/schema/migrations.md](./docs/schema/migrations.md) | migration 계획 |
313
+ | [docs/validation-rules.md](./docs/validation-rules.md) | validator rule 설명 |
@@ -0,0 +1,8 @@
1
+ {
2
+ "agentId": "document-agent",
3
+ "packageName": "agentic-domain-document",
4
+ "packageVersion": "0.6.0",
5
+ "moduleLayer": "domain",
6
+ "displayName": "Document Agent",
7
+ "description": "Document, TOC, Content, Typed Block 작성과 검증을 지원한다."
8
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "capabilityId": "document.authoring",
3
+ "description": "문서 목적, 독자, 목차, 본문 흐름을 기준으로 문서 초안과 보완안을 작성한다.",
4
+ "keywords": [
5
+ "Adoc",
6
+ "Agentic Document",
7
+ "Agentic Doc",
8
+ "agentic-domain-document",
9
+ "문서",
10
+ "본문",
11
+ "작성",
12
+ "초안",
13
+ "보완",
14
+ "개선"
15
+ ],
16
+ "examples": [
17
+ "Adoc 문서 초안을 작성해줘",
18
+ "문서 본문을 작성해줘",
19
+ "문서 내용을 보완해줘"
20
+ ]
21
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "capabilityId": "document.block",
3
+ "description": "Paragraph, Table, Diagram, Figure, List, Code, Callout, Quote 블록을 작성하고 검토한다.",
4
+ "keywords": [
5
+ "Adoc",
6
+ "Document Tree",
7
+ "Adoc Tree",
8
+ "블록",
9
+ "paragraph",
10
+ "table",
11
+ "diagram",
12
+ "figure",
13
+ "표",
14
+ "도해",
15
+ "그림"
16
+ ],
17
+ "examples": [
18
+ "Adoc Tree에서 특정 block을 찾아줘",
19
+ "표 블록을 작성해줘",
20
+ "다이어그램 설명을 보완해줘"
21
+ ]
22
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "capabilityId": "document.toc",
3
+ "description": "Document TOC Node 계층과 목차 표시 기준을 설계하고 검토한다.",
4
+ "keywords": [
5
+ "Adoc",
6
+ "Agentic Document",
7
+ "Document Tree",
8
+ "Adoc Tree",
9
+ "목차",
10
+ "TOC",
11
+ "Chapter",
12
+ "Section",
13
+ "Subsection",
14
+ "Heading"
15
+ ],
16
+ "examples": [
17
+ "Adoc Tree를 보여줘",
18
+ "문서 목차를 설계해줘",
19
+ "목차 구조를 검토해줘"
20
+ ]
21
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "capabilityId": "document.validation",
3
+ "description": "문서 구조, 용어, 문체, 표, 도해, 캡션, 원천/생성물 경계를 검증한다.",
4
+ "keywords": [
5
+ "Adoc",
6
+ "Agentic Document",
7
+ "Markdown Projection",
8
+ "Adoc Markdown Projection",
9
+ "검증",
10
+ "검토",
11
+ "품질",
12
+ "캡션",
13
+ "용어",
14
+ "표기"
15
+ ],
16
+ "examples": [
17
+ "Adoc Markdown Projection이 원천처럼 수정됐는지 검토해줘",
18
+ "문서 품질을 검토해줘",
19
+ "표기 규칙을 검증해줘"
20
+ ]
21
+ }