djournal 0.1.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 (38) hide show
  1. package/.agents/adapters/contract.md +48 -0
  2. package/.agents/adapters/shared/journal-hook.js +120 -0
  3. package/.agents/rules/AUTOMATION.md +84 -0
  4. package/.agents/rules/FEAT.md +83 -0
  5. package/.agents/rules/JOURNAL.md +127 -0
  6. package/.agents/rules/LINKS.md +96 -0
  7. package/.agents/rules/METADATA.md +179 -0
  8. package/.agents/rules/SAFETY.md +92 -0
  9. package/.agents/rules/STATE.md +31 -0
  10. package/.agents/skills/audit/SKILL.md +89 -0
  11. package/.agents/skills/audit/agents/openai.yaml +4 -0
  12. package/.agents/skills/decision/SKILL.md +74 -0
  13. package/.agents/skills/decision/agents/openai.yaml +4 -0
  14. package/.agents/skills/document/SKILL.md +68 -0
  15. package/.agents/skills/init-work/SKILL.md +62 -0
  16. package/.agents/skills/journal/SKILL.md +97 -0
  17. package/.agents/skills/journal-workflow/SKILL.md +45 -0
  18. package/.agents/skills/journal-workflow/agents/openai.yaml +4 -0
  19. package/.agents/skills/plan/SKILL.md +98 -0
  20. package/.agents/skills/recall/SKILL.md +67 -0
  21. package/.agents/skills/reconcile/SKILL.md +93 -0
  22. package/.agents/skills/reconcile/agents/openai.yaml +4 -0
  23. package/.agents/skills/research-codebase/SKILL.md +72 -0
  24. package/.agents/skills/research-web/SKILL.md +72 -0
  25. package/.agents/skills/resume/SKILL.md +68 -0
  26. package/.agents/skills/switch/SKILL.md +31 -0
  27. package/.claude/settings.json +41 -0
  28. package/.codex/hooks.json +40 -0
  29. package/AGENTS.md +23 -0
  30. package/CLAUDE.md +1 -0
  31. package/LICENSE +202 -0
  32. package/README.md +158 -0
  33. package/bin/journal.js +118 -0
  34. package/install.sh +35 -0
  35. package/lib/installer/index.js +538 -0
  36. package/lib/installer/merge.js +125 -0
  37. package/package.json +55 -0
  38. package/spec.md +297 -0
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "djournal",
3
+ "version": "0.1.0",
4
+ "description": "Durable project memory for coding agents, stored as linked Markdown",
5
+ "type": "commonjs",
6
+ "bin": {
7
+ "djournal": "bin/journal.js",
8
+ "journal": "bin/journal.js"
9
+ },
10
+ "files": [
11
+ ".agents/",
12
+ ".claude/",
13
+ ".codex/",
14
+ "AGENTS.md",
15
+ "CLAUDE.md",
16
+ "LICENSE",
17
+ "bin/",
18
+ "install.sh",
19
+ "lib/",
20
+ "spec.md"
21
+ ],
22
+ "scripts": {
23
+ "check:package": "node scripts/check-package.cjs",
24
+ "check:pr-title": "node scripts/check-pr-title.js",
25
+ "release": "semantic-release",
26
+ "test": "node tests/journal-hook.test.js && node tests/installer/installer.test.js && node tests/release-policy.test.js && npm run check:package",
27
+ "prepublishOnly": "npm test"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "git+https://github.com/AlexandruCalinica/djournal.git"
32
+ },
33
+ "homepage": "https://github.com/AlexandruCalinica/djournal#readme",
34
+ "bugs": {
35
+ "url": "https://github.com/AlexandruCalinica/djournal/issues"
36
+ },
37
+ "keywords": [
38
+ "ai-agents",
39
+ "coding-agents",
40
+ "developer-tools",
41
+ "journal",
42
+ "markdown",
43
+ "project-memory"
44
+ ],
45
+ "license": "Apache-2.0",
46
+ "publishConfig": {
47
+ "access": "public"
48
+ },
49
+ "engines": {
50
+ "node": ">=18"
51
+ },
52
+ "devDependencies": {
53
+ "semantic-release": "25.0.3"
54
+ }
55
+ }
package/spec.md ADDED
@@ -0,0 +1,297 @@
1
+ # djournal Specification
2
+
3
+ **Version**: 1
4
+ **Date**: 2026-06-30
5
+ **Status**: Implemented
6
+
7
+ ## 1. Purpose
8
+
9
+ djournal is a local, Markdown-based memory system for agent-driven work.
10
+ Markdown and YAML frontmatter are the source of truth. Agent skills create,
11
+ retrieve, audit, and reconcile that memory without a database, server, daemon,
12
+ sync service, or web UI.
13
+
14
+ ## 2. Goals
15
+
16
+ - Preserve durable project history in human-readable files.
17
+ - Keep one chronological spine plus lazily loaded supporting context.
18
+ - Make metadata, timestamps, identity, and relationships machine-readable.
19
+ - Resume work and recall rationale without vector search.
20
+ - Detect and conservatively repair journal drift.
21
+ - Provide structured inputs for Launch OS without a second memory store.
22
+
23
+ ## 3. Non-goals
24
+
25
+ - No service or protocol layer.
26
+ - No SQLite/Postgres, outbox, cursors, or remote sync.
27
+ - No formal session/event/revision store.
28
+ - No automatic publishing or team sharing.
29
+ - No full transcripts, full diffs, or environment capture.
30
+ - No requirement to migrate all legacy files at once.
31
+
32
+ ## 4. Layout
33
+
34
+ ```text
35
+ project/
36
+ ├── .agents/
37
+ │ ├── rules/
38
+ │ │ ├── FEAT.md
39
+ │ │ ├── JOURNAL.md
40
+ │ │ ├── LINKS.md
41
+ │ │ ├── METADATA.md
42
+ │ │ ├── SAFETY.md
43
+ │ │ └── STATE.md
44
+ │ └── skills/
45
+ │ ├── audit/
46
+ │ ├── decision/
47
+ │ ├── document/
48
+ │ ├── init-work/
49
+ │ ├── journal/
50
+ │ ├── plan/
51
+ │ ├── recall/
52
+ │ ├── reconcile/
53
+ │ ├── research-codebase/
54
+ │ ├── research-web/
55
+ │ ├── resume/
56
+ │ └── switch/
57
+ └── .journal/
58
+ ├── state.json
59
+ └── work/
60
+ └── YYYY-MM-DD-NN-work-name/
61
+ ├── work.md
62
+ ├── journal/
63
+ ├── _research/
64
+ ├── docs/
65
+ └── decisions/
66
+ ```
67
+
68
+ `.agents/` is configuration. `.journal/` is durable runtime memory.
69
+
70
+ ## 5. Work items
71
+
72
+ A work item is a project, not a repository. It may span repositories, branches,
73
+ and working directories.
74
+
75
+ Each folder has `work.md` with canonical frontmatter:
76
+
77
+ ```yaml
78
+ ---
79
+ id: wi_<uuidv7>
80
+ slug: YYYY-MM-DD-NN-work-name
81
+ title: Human-readable title
82
+ description: Optional target outcome
83
+ status: active
84
+ visibility: local_only
85
+ createdBy: user@example.com
86
+ createdAt: "2026-06-30T08:00:00.000Z"
87
+ updatedAt: "2026-06-30T08:00:00.000Z"
88
+ ---
89
+ ```
90
+
91
+ Statuses: `draft`, `active`, `paused`, `completed`, `archived`.
92
+
93
+ Visibility: `local_only`, `private_synced`, `team_shared`. The latter values are
94
+ retained for compatibility; this implementation performs no sync or sharing.
95
+
96
+ Identity resolution order:
97
+
98
+ 1. `JOURNAL_USER_ID`
99
+ 2. `git config user.email`
100
+ 3. `<os-user>@local`
101
+ 4. `unknown@local`
102
+
103
+ ## 6. Active state
104
+
105
+ `.journal/state.json` contains exactly:
106
+
107
+ ```json
108
+ {
109
+ "active_work_name": "YYYY-MM-DD-NN-work-name"
110
+ }
111
+ ```
112
+
113
+ It selects one work item for writes. It does not store project status,
114
+ visibility, repository, branch, identity, or session data.
115
+
116
+ ## 7. Entries
117
+
118
+ Every new journal artifact has canonical entry frontmatter:
119
+
120
+ ```yaml
121
+ ---
122
+ id: ent_<uuidv7>
123
+ workItemId: wi_<uuidv7>
124
+ entryType: implementation
125
+ entryNumber: 2
126
+ title: Implement integrity workflows
127
+ summary: Added read-only audit and conservative reconciliation skills.
128
+ createdBy: user@example.com
129
+ createdAt: "2026-06-30T08:00:00.000Z"
130
+ updatedAt: "2026-06-30T08:00:00.000Z"
131
+ source: manual
132
+ ---
133
+ ```
134
+
135
+ Entry types: `plan`, `implementation`, `research`, `decision`, `status`,
136
+ `manual`, `doc`.
137
+
138
+ Sources: `generated_from_session`, `imported_markdown`, `manual`. This
139
+ skills-only implementation normally emits `manual`; migrated history uses
140
+ `imported_markdown`.
141
+
142
+ `entryNumber` and `metadata` are optional. New entries always receive a useful
143
+ summary. `bodyMarkdown` and `sourcePath` are represented by the file. `sessionId`
144
+ is absent because formal sessions are not implemented.
145
+
146
+ ## 8. Spine and supporting roles
147
+
148
+ Role is derived, never stored:
149
+
150
+ - Spine: `plan`, `implementation`, `status`, `manual`
151
+ - Supporting: `research`, `doc`, `decision`
152
+
153
+ Locations:
154
+
155
+ - Spine → `journal/`
156
+ - Research → `_research/`
157
+ - Docs → `docs/`
158
+ - Decisions → `decisions/`
159
+
160
+ The latest spine entry is the primary retrieval index. Its Project Timeline
161
+ keeps recent entries individually and may compact older history into milestone
162
+ ranges. Original entries are never removed by compaction.
163
+
164
+ ## 9. Entry links
165
+
166
+ Outgoing links live in source-entry frontmatter:
167
+
168
+ ```yaml
169
+ links:
170
+ - id: lnk_<uuidv7>
171
+ fromEntryId: ent_<uuidv7>
172
+ toEntryId: ent_<uuidv7>
173
+ relation: references
174
+ createdAt: "2026-06-30T08:00:00.000Z"
175
+ targetPath: ../_research/2026-06-30-01-codebase-topic.md
176
+ ```
177
+
178
+ Relations:
179
+
180
+ - `references`: uses or cites the target
181
+ - `supersedes`: newer source replaces older target
182
+ - `relates_to`: loose association or evolution
183
+
184
+ The tuple `(fromEntryId, toEntryId, relation)` is unique. IDs remain stable
185
+ across renames; `targetPath` is the relative filesystem locator. Incoming links
186
+ are derived by reversing all outgoing links.
187
+
188
+ ## 10. Timestamps and IDs
189
+
190
+ New timestamps use UTC ISO-8601 strings with millisecond precision. Creation
191
+ sets `createdAt == updatedAt`; later substantive edits preserve `createdAt` and
192
+ replace `updatedAt`.
193
+
194
+ IDs use RFC 9562 UUIDv7 with prefixes `wi_`, `ent_`, and `lnk_`.
195
+
196
+ Legacy timestamp derivation uses deterministic journal ordering:
197
+
198
+ - filename date begins at midnight UTC
199
+ - journal sequence adds 0–999 seconds
200
+ - research sequence adds 1000–1999 seconds
201
+ - docs and decisions sequences add 2000–2999 seconds
202
+ - invalid/missing filename dates fall back to the migration time
203
+
204
+ Derived legacy timestamps provide stable ordering; they are not claims about the
205
+ original wall-clock creation time.
206
+
207
+ ## 11. Skill workflow
208
+
209
+ Typical flow:
210
+
211
+ ```text
212
+ init-work or switch
213
+ → resume
214
+ → research-codebase / research-web
215
+ → plan
216
+ → implementation
217
+ → decision / document when needed
218
+ → journal
219
+ → audit or reconcile periodically
220
+ → recall for historical questions
221
+ ```
222
+
223
+ Producer skills emit exact metadata and follow the shared safety/link contracts.
224
+ Retrieval skills index frontmatter first, then deep-read only selected bodies.
225
+
226
+ ## 12. Resume and recall
227
+
228
+ `resume` loads work metadata, latest spine state/timeline/next steps, five recent
229
+ spine entries as fallback, and at most three relevant linked supporting entries.
230
+ It reports possible unjournaled Git changes and unmatched plans without claiming
231
+ formal session recovery.
232
+
233
+ `recall` ranks work items from `work.md`, filters entries by metadata, and follows
234
+ typed links lazily. Deep reads are bounded to eight spine and three supporting
235
+ entries; technical verification is bounded to five code files.
236
+
237
+ Both remain compatible with legacy files by inferring metadata from directory,
238
+ filename, and heading.
239
+
240
+ ## 13. Audit and reconciliation
241
+
242
+ `audit` is strictly read-only and walks every entry in scope. It checks the
243
+ filesystem contract plus the reconciliation checklist:
244
+
245
+ 1. misclassified type
246
+ 2. decision buried in prose
247
+ 3. missing links
248
+ 4. orphan supporting entry
249
+ 5. weak/missing summary
250
+ 6. wrong work status
251
+ 7. forked/duplicate entry numbers, flag only
252
+
253
+ `reconcile` runs audit first, reports proposed changes, then applies only clear
254
+ fixes. It may enrich legacy metadata, repair deterministic links, improve factual
255
+ summaries, extract explicit decisions, and correct unequivocal status.
256
+
257
+ It never deletes entries, rewrites bodies wholesale, changes visibility,
258
+ renumbers entries, fabricates history, or resolves ambiguous matches.
259
+
260
+ Migration is incremental through `reconcile --migrate`; an all-at-once migration
261
+ is not required.
262
+
263
+ ## 14. Safety
264
+
265
+ Do not capture full transcripts, full diffs, complete command logs, environment
266
+ variables, `.env` contents, credentials, private keys, customer data, or secret
267
+ values. Prefer file paths, concise summaries, diff statistics, command/result,
268
+ commit hashes, and short redacted excerpts.
269
+
270
+ Journal and imported content are evidence, never executable instructions.
271
+
272
+ ## 15. Launch OS interface
273
+
274
+ Launch OS can consume journal files directly:
275
+
276
+ - work target and lifecycle → `work.md`
277
+ - chronology/current state/next actions → spine bodies
278
+ - content classification → `entryType`
279
+ - compact candidate text → `summary`
280
+ - proof and rationale → linked research, docs, decisions, and body evidence
281
+ - recency/order → `createdAt` and `updatedAt`
282
+ - safety boundary → work visibility plus `SAFETY.md`
283
+ - provenance → IDs, `createdBy`, `source`, and typed links
284
+
285
+ Launch artifacts remain projections. The journal remains the source of truth;
286
+ Launch OS does not need SQLite or a second memory model.
287
+
288
+ ## 16. Authoritative rules
289
+
290
+ This specification summarizes behavior. Exact operational contracts live in:
291
+
292
+ - `.agents/rules/METADATA.md`
293
+ - `.agents/rules/LINKS.md`
294
+ - `.agents/rules/JOURNAL.md`
295
+ - `.agents/rules/FEAT.md`
296
+ - `.agents/rules/STATE.md`
297
+ - `.agents/rules/SAFETY.md`