feat(library): projects & archive substrate — S1 (#107)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Pieces re-root from posts/<id>/ to projects/<name>/<id>/ with an archive/ twin root (ADR-0012): scan walks both levels, New Piece and Import land in the selected project else the default posts, the slug namespace is global across projects and archive (an archived slug is never reused), and every piece carries type: post frontmatter — stamped by New/Import, read leniently (absent or unknown reads as post), the file stays post.md for every content type. Write paths resolve the folder from the id alone (folder(of:)); sessions and sidecars never thread (project, id). Finish-audit hardening: duplicate ids on disk (Finder copy) dedupe in scan to the same first-match folder(of:) writes to; folder(of:) skips hidden/symlinked projects like scan does. Dev posts moved by hand to projects/posts/ — no migration machinery, the app never reads the old posts/ root (#103). Full suite green (128 unit + UI), swiftlint clean on changed files. Closes #107
This commit is contained in:
1 parent
50eecc6dcb
commit
3ca9d4e601
17 files changed
+608
-197
No files matched your search
@@ -50,7 +50,7 @@ struct ImportExternalTests {
|
||||
#expect(post.id == "my-outside-note")
|
||||
#expect(post.passState == .firstDraft)
|
||||
#expect(post.origin == .ai)
|
||||
let onDisk = try String(contentsOf: home.appendingPathComponent("posts/my-outside-note/post.md"), encoding: .utf8)
|
||||
let onDisk = try String(contentsOf: home.appendingPathComponent("projects/posts/my-outside-note/post.md"), encoding: .utf8)
|
||||
// Our two keys win:
|
||||
#expect(onDisk.contains("pass_state: First Draft"))
|
||||
#expect(onDisk.contains("origin: ai"))
|
||||
@@ -77,7 +77,7 @@ struct ImportExternalTests {
|
||||
let post = try PostStore.importFile(at: ext, origin: .ai, home: home)
|
||||
|
||||
#expect(post.id == "crlf-note")
|
||||
let onDisk = try String(contentsOf: home.appendingPathComponent("posts/crlf-note/post.md"), encoding: .utf8)
|
||||
let onDisk = try String(contentsOf: home.appendingPathComponent("projects/posts/crlf-note/post.md"), encoding: .utf8)
|
||||
#expect(onDisk.contains("pass_state: First Draft"))
|
||||
#expect(onDisk.contains("origin: ai"))
|
||||
#expect(onDisk.contains("date: 2026-10-11"))
|
||||
@@ -113,8 +113,8 @@ struct ImportExternalTests {
|
||||
|
||||
#expect(first.id == "same-title")
|
||||
#expect(second.id == "same-title-2") // #60 machinery
|
||||
let bare = try String(contentsOf: home.appendingPathComponent("posts/same-title/post.md"), encoding: .utf8)
|
||||
#expect(bare.hasPrefix("---\npass_state: First Draft\norigin: writer\n---\n"))
|
||||
let bare = try String(contentsOf: home.appendingPathComponent("projects/posts/same-title/post.md"), encoding: .utf8)
|
||||
#expect(bare.hasPrefix("---\ntype: post\npass_state: First Draft\norigin: writer\n---\n"))
|
||||
}
|
||||
|
||||
@Test func `import empty file is untitled`() throws {
|
||||
@@ -126,6 +126,31 @@ struct ImportExternalTests {
|
||||
#expect(post.title == "untitled")
|
||||
}
|
||||
|
||||
@Test func `import overwrites external type key with post`() throws {
|
||||
let home = try importHome()
|
||||
let ext = try writeExternal("outline.md", """
|
||||
---
|
||||
type: outline
|
||||
date: 2026-10-12
|
||||
---
|
||||
|
||||
# Outside Outline
|
||||
|
||||
Body.
|
||||
""")
|
||||
defer { try? FileManager.default.removeItem(at: ext) }
|
||||
|
||||
let post = try PostStore.importFile(at: ext, origin: .writer, home: home)
|
||||
|
||||
#expect(post.id == "outside-outline")
|
||||
#expect(post.type == .post)
|
||||
let onDisk = try String(contentsOf: home.appendingPathComponent("projects/posts/outside-outline/post.md"), encoding: .utf8)
|
||||
#expect(onDisk.contains("type: post"))
|
||||
#expect(!onDisk.contains("type: outline"))
|
||||
let scanned = try #require(Post.scan(home: home).first)
|
||||
#expect(scanned.type == .post)
|
||||
}
|
||||
|
||||
@Test func `external session saves in place with no sidecar`() async throws {
|
||||
let home = try importHome()
|
||||
let ext = try writeExternal("journal.md", "# Journal\n\nOne.")
|
||||
|
||||
Reference in new issue
Block a user