pi-ext
bugabingas pi extensions
owned by bugabinga
fix(system): allow absent empty collections
7f2caf5f2a21d5271ced2777f27370b9e21f61ca
Oliver Jan Krylow <oliver@bugabinga.net> ·
SSH signature · not checked
Browse filesCompare with HEAD
Changed files (5)
extensions/the-system/__tests__/doctor.test.ts
Modified 30 30 const markdown = (id
: string, type
= "spec", extra
= "")
=> 31 31 `---\nid: ${id}\ntype: ${type}\ntitle: Contract${extra}\n---\n\n# Contract\n`;
32 32 const validSystem = (root
: string)
=> {
33 - for (
const directory
of [
"specs",
"phases",
"plans",
"issues",
"research"])
34 - mkdirSync(path.
join(
root,
".system", directory), { recursive:
true });
35 33 for (
const file
of [
"SYSTEM.md",
"MISSION.md",
"RULES.md"])
36 34 write(
root,
`.system/${file}`,
`# ${file}\n`);
37 35 write(
root,
".system/config.json",
'{"prefix":"PX","schemaVersion":0}');
75 73 describe(
"system doctor", ()
=> {
76 - it(
"requires config, cores, and typed directories but not CSS", ()
=> {
74 + it(
"requires the system root, config, and cores but not empty collections", ()
=> {
77 75 const root
= temporaryRoot();
78 76 const result
= runDoctor(
root);
85 83 ".system/SYSTEM.md filesystem.missing",
86 84 ".system/board.json filesystem.missing",
87 85 ".system/config.json filesystem.missing",
88 - ".system/issues filesystem.missing",
89 - ".system/phases filesystem.missing",
90 - ".system/plans filesystem.missing",
91 - ".system/research filesystem.missing",
92 - ".system/specs filesystem.missing",
90 + it(
"rejects collection paths that are not regular directories", ()
=> {
91 + const root
= temporaryRoot();
92 + const outside
= temporaryRoot();
94 + write(
root,
".system/issues",
"not a directory");
96 + runDoctor(
root).diagnostics.
map(({ code, path })
=> `${path} ${code}`),
97 + [
".system/issues bundle.expected-directory"],
99 + rmSync(path.
join(
root,
".system/issues"));
100 + symlinkSync(outside, path.
join(
root,
".system/issues"),
"dir");
102 + runDoctor(
root).diagnostics.
map(({ code, path })
=> `${path} ${code}`),
103 + [
".system/issues bundle.symbolic-link"],
97 107 it(
"combines shared bundle, graph, and test diagnostics", ()
=> {
98 108 const root
= temporaryRoot();
99 109 validSystem(
root);
extensions/the-system/__tests__/init.test.ts
Modified 76 76 readFileSync(path.
join(project,
".system/RULES.md"),
"utf8"),
77 77 /Concrete operating constraints/,
79 + for (
const directory
of [
"specs",
"phases",
"plans",
"issues",
"research"])
81 + lstatSync(path.
join(project,
".system", directory), {
82 + throwIfNoEntry:
false,
79 86 const before
= [
"SYSTEM.md",
"MISSION.md",
"RULES.md"].
map((name)
=> {
80 87 const target
= path.
join(project,
".system", name);
81 88 return [name,
readFileSync(target,
"utf8"),
lstatSync(target).mtimeMs];
extensions/the-system/doctor.ts
Modified 23 -const SYSTEM_DIRECTORIES
= [
23 +const SYSTEM_DIRECTORIES
= [
".system"]
as const;
31 24 const SYSTEM_FILES
= [
32 25 ".system/config.json",
extensions/the-system/documents.ts
Modified589 589 const directoryStats
= lstatSync(absoluteDirectory, {
590 590 throwIfNoEntry:
false,
592 - if (
!directoryStats?.
isDirectory()
|| directoryStats.
isSymbolicLink())
592 + if (
!directoryStats)
continue;
593 + if (directoryStats.
isSymbolicLink()) {
596 + "bundle.symbolic-link",
598 + `Bundle path is a symbolic link: ${relativeDirectory}`,
603 + if (
!directoryStats.
isDirectory()) {
606 + "bundle.expected-directory",
608 + `Expected a document collection directory: ${relativeDirectory}`,
594 613 for (
const entry
of readdirSync(absoluteDirectory, {
595 614 withFileTypes:
true,
596 615 }).
sort((left, right)
=> left.
name.
localeCompare(right.
name))) {
extensions/the-system/init.ts
Modified 32 32 pending: readonly string[];
35 -const DIRECTORIES
= [
35 +const DIRECTORIES
= [
".system"]
as const;
36 +const COLLECTION_DIRECTORIES
= [
106 106 ): InitializationInspection {
107 107 const root
= discoverProjectRoot(cwd);
108 108 for (
const relative
of DIRECTORIES)
requireKind(
root, relative,
"directory");
109 + for (
const relative
of COLLECTION_DIRECTORIES)
110 + requireKind(
root, relative,
"directory");
109 111 const configKind
= requireKind(
root, CONFIG,
"file");
110 112 const boardKind
= requireKind(
root, BOARD_PATH,
"file");
111 113 const requested
= requestedPrefix