hub-project-from-path.test.mjs
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠ breaking
2 days ago
| 1 | /** |
| 2 | * Contract for vault path → project slug (mirrors web/hub/hub.js projectSlugFromProjectsPath). |
| 3 | */ |
| 4 | import { describe, it } from 'node:test'; |
| 5 | import assert from 'node:assert'; |
| 6 | |
| 7 | function projectSlugFromProjectsPath(path) { |
| 8 | if (!path || typeof path !== 'string') return null; |
| 9 | const m = path.match(/^projects\/([^/]+)(?:\/|$)/); |
| 10 | return m ? m[1] : null; |
| 11 | } |
| 12 | |
| 13 | function projectsPathTypoSuggestion(path) { |
| 14 | const p = String(path || '').trim(); |
| 15 | if (!p) return null; |
| 16 | if (/^project\//.test(p) && !/^projects\//.test(p)) return p.replace(/^project\//, 'projects/'); |
| 17 | return null; |
| 18 | } |
| 19 | |
| 20 | describe('project slug from projects/… vault paths', () => { |
| 21 | it('returns first segment after projects/', () => { |
| 22 | assert.strictEqual(projectSlugFromProjectsPath('projects/foo/inbox/x.md'), 'foo'); |
| 23 | assert.strictEqual(projectSlugFromProjectsPath('projects/bar-baz/note.md'), 'bar-baz'); |
| 24 | }); |
| 25 | |
| 26 | it('returns null when not under projects/', () => { |
| 27 | assert.strictEqual(projectSlugFromProjectsPath('inbox/x.md'), null); |
| 28 | assert.strictEqual(projectSlugFromProjectsPath('deep/projects/no.md'), null); |
| 29 | assert.strictEqual(projectSlugFromProjectsPath(null), null); |
| 30 | }); |
| 31 | |
| 32 | it('treats projects/foo.md as segment foo.md (single path component)', () => { |
| 33 | assert.strictEqual(projectSlugFromProjectsPath('projects/foo.md'), 'foo.md'); |
| 34 | }); |
| 35 | }); |
| 36 | |
| 37 | describe('projects/ vs project/ typo fix suggestion', () => { |
| 38 | it('rewrites project/ prefix to projects/', () => { |
| 39 | assert.strictEqual(projectsPathTypoSuggestion('project/acme/inbox/x.md'), 'projects/acme/inbox/x.md'); |
| 40 | }); |
| 41 | |
| 42 | it('does not rewrite valid projects/ paths', () => { |
| 43 | assert.strictEqual(projectsPathTypoSuggestion('projects/acme/inbox/x.md'), null); |
| 44 | }); |
| 45 | |
| 46 | it('does not treat unrelated paths as typos', () => { |
| 47 | assert.strictEqual(projectsPathTypoSuggestion('inbox/x.md'), null); |
| 48 | assert.strictEqual(projectsPathTypoSuggestion('deep/project/file.md'), null); |
| 49 | }); |
| 50 | }); |
File History
2 commits
sha256:65ccb454656ea5acdea0a10e559b78bcde1eb6ff753ecc2911bc99d1c3d7cadd
feat(calendar): enforce agent context tiers in retrieval AP…
Human
minor
⚠
2 days ago
sha256:9103f98c89257ed2b01c237cea895dabb3e85ea337dccb1161c175e4422355b6
docs: accept Calendar Events v0 spec with Phase 0 security …
Human
2 days ago