mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 10:21:52 +00:00
* add documentation for ai agents * docs: consolidate CLAUDE.md and CONTRIBUTING.md, add style guidelines - Refactor CLAUDE.md to reference CONTRIBUTING.md for build/test/format info - Expand CONTRIBUTING.md with comprehensive build targets, env vars, and testing - Add code style guidelines section with conventional commits - Standardize SDK prettier config to use single quotes (matching web) - Add project-level Claude Code settings to disable co-author attribution * style(sdk): apply prettier with single quotes Run prettier across sdk/base and sdk/package to apply the standardized quote style (single quotes matching web). * docs: add USER.md for per-developer TODO filtering - Add agents/USER.md to .gitignore (contains user identifier) - Document session startup flow in CLAUDE.md: - Create USER.md if missing, prompting for identifier - Filter TODOs by @username tags - Offer relevant TODOs on session start * docs: add i18n documentation task to agent TODOs * docs: document i18n ID patterns in core/ Add agents/i18n-patterns.md covering rust-i18n setup, translation file format, t!() macro usage, key naming conventions, and locale selection. Remove completed TODO item and add reference in CLAUDE.md. * chore: clarify that all builds work on any OS with Docker
149 lines
4.2 KiB
TypeScript
149 lines
4.2 KiB
TypeScript
import { Graph } from '../util'
|
|
|
|
describe('graph', () => {
|
|
{
|
|
{
|
|
test('findVertex', () => {
|
|
const graph = new Graph<string, string>()
|
|
const foo = graph.addVertex('foo', [], [])
|
|
const bar = graph.addVertex(
|
|
'bar',
|
|
[{ from: foo, metadata: 'foo-bar' }],
|
|
[],
|
|
)
|
|
const baz = graph.addVertex(
|
|
'baz',
|
|
[{ from: bar, metadata: 'bar-baz' }],
|
|
[],
|
|
)
|
|
const qux = graph.addVertex(
|
|
'qux',
|
|
[{ from: baz, metadata: 'baz-qux' }],
|
|
[],
|
|
)
|
|
const match = Array.from(graph.findVertex((v) => v.metadata === 'qux'))
|
|
expect(match).toHaveLength(1)
|
|
expect(match[0]).toBe(qux)
|
|
})
|
|
test('shortestPathA', () => {
|
|
const graph = new Graph<string, string>()
|
|
const foo = graph.addVertex('foo', [], [])
|
|
const bar = graph.addVertex(
|
|
'bar',
|
|
[{ from: foo, metadata: 'foo-bar' }],
|
|
[],
|
|
)
|
|
const baz = graph.addVertex(
|
|
'baz',
|
|
[{ from: bar, metadata: 'bar-baz' }],
|
|
[],
|
|
)
|
|
const qux = graph.addVertex(
|
|
'qux',
|
|
[{ from: baz, metadata: 'baz-qux' }],
|
|
[],
|
|
)
|
|
graph.addEdge('foo-qux', foo, qux)
|
|
expect(graph.shortestPath(foo, qux) || []).toHaveLength(1)
|
|
})
|
|
test('shortestPathB', () => {
|
|
const graph = new Graph<string, string>()
|
|
const foo = graph.addVertex('foo', [], [])
|
|
const bar = graph.addVertex(
|
|
'bar',
|
|
[{ from: foo, metadata: 'foo-bar' }],
|
|
[],
|
|
)
|
|
const baz = graph.addVertex(
|
|
'baz',
|
|
[{ from: bar, metadata: 'bar-baz' }],
|
|
[],
|
|
)
|
|
const qux = graph.addVertex(
|
|
'qux',
|
|
[{ from: baz, metadata: 'baz-qux' }],
|
|
[],
|
|
)
|
|
graph.addEdge('bar-qux', bar, qux)
|
|
expect(graph.shortestPath(foo, qux) || []).toHaveLength(2)
|
|
})
|
|
test('shortestPathC', () => {
|
|
const graph = new Graph<string, string>()
|
|
const foo = graph.addVertex('foo', [], [])
|
|
const bar = graph.addVertex(
|
|
'bar',
|
|
[{ from: foo, metadata: 'foo-bar' }],
|
|
[],
|
|
)
|
|
const baz = graph.addVertex(
|
|
'baz',
|
|
[{ from: bar, metadata: 'bar-baz' }],
|
|
[],
|
|
)
|
|
const qux = graph.addVertex(
|
|
'qux',
|
|
[{ from: baz, metadata: 'baz-qux' }],
|
|
[{ to: foo, metadata: 'qux-foo' }],
|
|
)
|
|
expect(graph.shortestPath(foo, qux) || []).toHaveLength(3)
|
|
})
|
|
test('bfs', () => {
|
|
const graph = new Graph<string, string>()
|
|
const foo = graph.addVertex('foo', [], [])
|
|
const bar = graph.addVertex(
|
|
'bar',
|
|
[{ from: foo, metadata: 'foo-bar' }],
|
|
[],
|
|
)
|
|
const baz = graph.addVertex(
|
|
'baz',
|
|
[{ from: bar, metadata: 'bar-baz' }],
|
|
[],
|
|
)
|
|
const qux = graph.addVertex(
|
|
'qux',
|
|
[
|
|
{ from: foo, metadata: 'foo-qux' },
|
|
{ from: baz, metadata: 'baz-qux' },
|
|
],
|
|
[],
|
|
)
|
|
const bfs = Array.from(graph.breadthFirstSearch(foo))
|
|
expect(bfs).toHaveLength(4)
|
|
expect(bfs[0]).toBe(foo)
|
|
expect(bfs[1]).toBe(bar)
|
|
expect(bfs[2]).toBe(qux)
|
|
expect(bfs[3]).toBe(baz)
|
|
})
|
|
test('reverseBfs', () => {
|
|
const graph = new Graph<string, string>()
|
|
const foo = graph.addVertex('foo', [], [])
|
|
const bar = graph.addVertex(
|
|
'bar',
|
|
[{ from: foo, metadata: 'foo-bar' }],
|
|
[],
|
|
)
|
|
const baz = graph.addVertex(
|
|
'baz',
|
|
[{ from: bar, metadata: 'bar-baz' }],
|
|
[],
|
|
)
|
|
const qux = graph.addVertex(
|
|
'qux',
|
|
[
|
|
{ from: foo, metadata: 'foo-qux' },
|
|
{ from: baz, metadata: 'baz-qux' },
|
|
],
|
|
[],
|
|
)
|
|
const bfs = Array.from(graph.reverseBreadthFirstSearch(qux))
|
|
expect(bfs).toHaveLength(4)
|
|
expect(bfs[0]).toBe(qux)
|
|
expect(bfs[1]).toBe(foo)
|
|
expect(bfs[2]).toBe(baz)
|
|
expect(bfs[3]).toBe(bar)
|
|
})
|
|
}
|
|
}
|
|
})
|