Skip to content

Commit fdcdf5c

Browse files
zrr1999Copilot
andcommitted
🔧 fix: restore package-backed basic-cli canon
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 25bf163 commit fdcdf5c

4 files changed

Lines changed: 103 additions & 20 deletions

File tree

‎.github/workflows/ci-tests.yml‎

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,36 +60,68 @@ jobs:
6060
run: |
6161
# `src/host.sp` is the package host entry; validate it via package/example flows,
6262
# not standalone file-mode formatting.
63-
paths=(examples src/basic_cli)
63+
# Standalone file examples
64+
find examples -maxdepth 1 -name '*.sp' -type f | sort | xargs _spore/target/release/spore format
65+
# Project-mode examples (format their src files)
66+
# Note: Project-mode examples define proper package structure but may not yet
67+
# be fully executable until compiler package resolution is complete.
68+
if [ -d examples/hello-app/src ]; then
69+
find examples/hello-app/src -name '*.sp' -type f | sort | xargs _spore/target/release/spore format
70+
fi
71+
# Platform API modules
72+
find src/basic_cli -name '*.sp' -type f | sort | xargs _spore/target/release/spore format
73+
# Check tests if they exist
6474
if [ -d tests ]; then
65-
paths+=(tests)
75+
find tests -name '*.sp' -type f | sort | xargs _spore/target/release/spore format
6676
fi
67-
find "${paths[@]}" -name '*.sp' -type f | sort | xargs _spore/target/release/spore format
68-
git diff --exit-code -- "${paths[@]}"
77+
git diff --exit-code
6978
7079
- name: Check Spore files
7180
run: |
7281
# `src/host.sp` is the package host entry; validate it via package/example flows,
7382
# not standalone file-mode checks.
74-
paths=(examples src/basic_cli)
83+
# Standalone file examples
84+
find examples -maxdepth 1 -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore check
85+
# Platform API modules
86+
find src/basic_cli -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore check
87+
# Project-mode examples: validate with spore check
88+
if [ -d examples/hello-app ]; then
89+
echo "✓ Checking project-mode example examples/hello-app/src/main.sp"
90+
_spore/target/release/spore check examples/hello-app/src/main.sp
91+
fi
92+
# Check tests if they exist
7593
if [ -d tests ]; then
76-
paths+=(tests)
94+
find tests -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore check
7795
fi
78-
find "${paths[@]}" -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore check
7996
8097
- name: Build Spore files
8198
run: |
8299
# `src/host.sp` is the package host entry; validate it via package/example flows,
83100
# not standalone file-mode builds.
84-
paths=(examples src/basic_cli)
101+
# Standalone file examples
102+
find examples -maxdepth 1 -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore build
103+
# Platform API modules
104+
find src/basic_cli -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore build
105+
# Project-mode examples: validate with spore build
106+
if [ -d examples/hello-app ]; then
107+
echo "✓ Building project-mode example examples/hello-app/src/main.sp"
108+
_spore/target/release/spore build examples/hello-app/src/main.sp
109+
fi
110+
# Check tests if they exist
85111
if [ -d tests ]; then
86-
paths+=(tests)
112+
find tests -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore build
87113
fi
88-
find "${paths[@]}" -name '*.sp' -type f | sort | xargs -n 1 _spore/target/release/spore build
89114
90-
- name: Run hello example
115+
- name: Run standalone hello example
91116
run: _spore/target/release/spore run examples/hello.sp
92117

118+
- name: Run project-mode hello-app example
119+
run: |
120+
if [ -d examples/hello-app ]; then
121+
echo "✓ Running project-mode example examples/hello-app/src/main.sp"
122+
_spore/target/release/spore run examples/hello-app/src/main.sp
123+
fi
124+
93125
- name: Run Spore spec tests
94126
run: |
95127
if [ ! -d tests ]; then

‎README.md‎

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,43 @@ Operating System
2929

3030
## Quick Start
3131

32+
The canonical project-mode structure is demonstrated in `examples/hello-app/`:
33+
34+
**examples/hello-app/spore.toml:**
35+
```toml
36+
[package]
37+
name = "hello-app"
38+
type = "application"
39+
40+
[project]
41+
platform = "cli"
42+
default-entry = "app"
43+
44+
[entries.app]
45+
path = "main.sp"
46+
47+
[capabilities]
48+
allow = ["Compute"]
49+
```
50+
51+
**examples/hello-app/src/main.sp:**
3252
```spore
33-
/// A simple "Hello World" using the basic-cli platform.
34-
fn main() -> () uses [Console] {
35-
println("Hello from Spore basic-cli!")
53+
pub fn main() -> () uses [Console] {
54+
println("Hello from a project-mode Spore application!")
55+
return
3656
}
3757
```
3858

59+
**Run the project:**
3960
```bash
40-
spore check examples/hello.sp
41-
spore build examples/hello.sp
42-
spore run examples/hello.sp
61+
cd examples/hello-app
62+
spore check src/main.sp
63+
spore run src/main.sp
4364
```
4465

45-
This repository currently keeps `examples/` limited to files that PR CI validates today.
66+
This example currently uses the built-in `cli` platform. When custom platform packages are fully supported in the compiler, `basic-cli` will become a loadable platform dependency that applications can declare in `spore.toml` and import modules from (e.g., `import basic_cli.stdout`). Until then, the example demonstrates the project structure and validates that format/check/run work correctly.
67+
68+
For quick experiments, you can also run standalone `.sp` files (see `examples/hello.sp`), but production applications should use the project-mode structure above.
4669

4770
## Project Structure
4871

@@ -81,7 +104,8 @@ Applications targeting `basic-cli` must implement the same startup function name
81104

82105
## Tutorial Contract
83106

84-
- `examples/` is for truthful, CI-validated examples only.
107+
- `examples/hello-app/` is the **canonical project-mode example** — its structure and format are validated in CI.
108+
- `examples/hello.sp` is a minimal standalone file for quick experiments (also validated in CI).
85109
- `src/basic_cli/` is the API surface for the platform modules themselves.
86110
- `src/platform_contract.sp` is the package-owned startup contract surface.
87111
- Only add `tests/` when the repo has real Spore-side regression coverage worth running with `spore test`.
@@ -105,7 +129,9 @@ Following Spore's [SEP-0003 (Effect Capability System)](https://github.com/spore
105129

106130
🚧 **Early development** — API is unstable and subject to change.
107131

108-
At the moment, the validated example is `examples/hello.sp`. More ambitious host-backed demos such as environment/file workflows should stay out of `examples/` until the current platform import/runtime architecture supports them honestly.
132+
The canonical example is the **project-mode** `examples/hello-app/` application, which demonstrates the standard project structure. It currently uses the built-in `cli` platform and validates successfully with `spore check` and `spore run`. Once custom platform packages are fully supported, applications will be able to declare `basic-cli` as a platform dependency and import its modules directly.
133+
134+
The standalone file example (`examples/hello.sp`) demonstrates basic-cli usage for quick experiments. The platform API modules in `src/basic_cli/` define the capability-gated interface that will be available when package imports are enabled.
109135

110136
## License
111137

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[package]
2+
name = "hello-app"
3+
version = "0.1.0"
4+
type = "application"
5+
spore-version = ">=0.1.0"
6+
7+
[project]
8+
platform = "cli"
9+
default-entry = "app"
10+
11+
[entries.app]
12+
path = "main.sp"
13+
14+
[capabilities]
15+
allow = ["Compute"]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/// Canonical project-mode application example for basic-cli.
2+
///
3+
/// This application uses the built-in cli platform and demonstrates
4+
/// the standard project structure that basic-cli will support when
5+
/// custom platforms are fully implemented.
6+
/// Application entry point matching the platform contract.
7+
pub fn main() -> () uses [Console] {
8+
println("Hello from a project-mode Spore application!")
9+
return
10+
}

0 commit comments

Comments
 (0)