@simway/spica 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1 -1
- package/package.json +2 -1
- package/skills/spica-architect/SKILL.md +188 -0
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { projectKiroSpec } from "./kiroSpecProjector.js";
|
|
|
8
8
|
import { projectOpenApi3Spec } from "./openApiProjector.js";
|
|
9
9
|
import { projectDomainAggregateMap, projectSystemContextDiagram } from "./diagramProjector.js";
|
|
10
10
|
import { CLAUDE_CODE_TEMPLATE, CODEX_TEMPLATE, VSCODE_SETTINGS_TEMPLATE, } from "./initTemplates.js";
|
|
11
|
-
const VERSION = "0.0.
|
|
11
|
+
const VERSION = "0.0.5";
|
|
12
12
|
function printHelp() {
|
|
13
13
|
console.log(`
|
|
14
14
|
Spica CLI 🌟 v${VERSION}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simway/spica",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "Canonical TypeScript/Zod Open ADM schema, invariant validator, multi-lens specification and diagram projectors, and DDD Crew markdown parser for Spica",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
"dist",
|
|
12
|
+
"skills",
|
|
12
13
|
"LICENSE",
|
|
13
14
|
"README.md"
|
|
14
15
|
],
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: spica-architect
|
|
3
|
+
description: Use when planning non-trivial features, designing state machines or entity lifecycles, establishing API contracts, untangling complex business logic, or validating domain invariants with Spica Open ADM.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Spica Architect Skill 🌟
|
|
7
|
+
> **Spec-Driven Development (SDD) & Mathematical Invariant Architecture for Autonomous AI Agents**
|
|
8
|
+
|
|
9
|
+
This skill equips AI coding agents (Claude Code, Cursor, OpenClaw, Windsurf) to guide human users through Domain-Driven Design and project specifications across multiple lenses using the `@simway/spica` engine.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## When to Use This Skill
|
|
14
|
+
- The user asks to:
|
|
15
|
+
- "Plan or architect a new feature / complex workflow before writing code"
|
|
16
|
+
- "Design or debug state machines, transitions, or entity lifecycles"
|
|
17
|
+
- "Create a specification / PRD"
|
|
18
|
+
- "Generate AWS Kiro specs (`.kiro/specs/`)"
|
|
19
|
+
- "Generate an OpenAPI contract from business rules or for frontend/backend handoffs"
|
|
20
|
+
- "Validate domain invariants or untangle contradictory conditional logic"
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Installation & Setup Tracks
|
|
25
|
+
|
|
26
|
+
1. **Agent Skill (one-time, human-run):** installs this reusable skill into your AI coding agent (Claude Code, Cursor, OpenClaw, Windsurf).
|
|
27
|
+
```bash
|
|
28
|
+
npx skills add sim-way/spica --skill spica-architect
|
|
29
|
+
```
|
|
30
|
+
2. **Global Standalone CLI (recommended for fast local & agent execution):**
|
|
31
|
+
```bash
|
|
32
|
+
npm i -g @simway/spica # or: pnpm add -g @simway/spica
|
|
33
|
+
```
|
|
34
|
+
3. **Project / Developer CLI (durable, versioned team tooling):** pins the CLI as a devDependency.
|
|
35
|
+
```bash
|
|
36
|
+
npm i -D @simway/spica # or: pnpm add -D @simway/spica
|
|
37
|
+
```
|
|
38
|
+
4. **Zero-install (ad-hoc):** no local install — invoke with `npx -y @simway/spica <command>` (or `bunx`, `pnpm dlx`).
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Verification & Architecture Strategy
|
|
43
|
+
|
|
44
|
+
Spica enforces mathematical domain soundness via the deterministic `@simway/spica` compiler engine and JSON Schema, **not** through fuzzy prompt-time rule guessing.
|
|
45
|
+
|
|
46
|
+
Agents operate on two complementary execution paths:
|
|
47
|
+
|
|
48
|
+
- **Terminal / CLI Mode (Preferred — Node/Bun/pnpm available):**
|
|
49
|
+
Execute `spica validate` (or `npx -y @simway/spica validate`) and projector commands directly in the terminal for sub-second, deterministic invariant enforcement.
|
|
50
|
+
- **Browser Studio Mode (Fallback — No Node / Non-JS / Chat-Only):**
|
|
51
|
+
If running in an environment without Node/terminal access (e.g. Python, Go, Rust minimal container, or web chat), author `<domain>.adm.json` referencing the schema and generate the 1-click preview link:
|
|
52
|
+
`https://spica.simway.io/#spec=<base64>`
|
|
53
|
+
The browser runs `@simway/spica` client-side, validating invariants and projecting all 5 lenses with **zero Node.js dependencies on the host**.
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Operational Execution Protocol (Step-by-Step)
|
|
58
|
+
|
|
59
|
+
### Step 0: Workspace Tooling Check (Optional)
|
|
60
|
+
If terminal access is available, check whether the project is already equipped with Spica tooling:
|
|
61
|
+
- If `CLAUDE.md`, `CODEX.md`, or `.vscode/settings.json` are absent and the user plans to do recurring Spec-Driven Development in this repository, offer to initialize them:
|
|
62
|
+
> *"Would you like me to bootstrap Spica IDE configurations (`CLAUDE.md`, `CODEX.md`, `.vscode/settings.json`) in this project?"*
|
|
63
|
+
- To initialize:
|
|
64
|
+
```bash
|
|
65
|
+
spica init # or: npx -y @simway/spica init
|
|
66
|
+
```
|
|
67
|
+
- Do not blindly overwrite existing files; `spica init` safely skips existing configs unless `--force` is passed.
|
|
68
|
+
|
|
69
|
+
### Step 1: Conversational Elicitation (4-Stage Socratic Discovery)
|
|
70
|
+
If the user's intent is incomplete or ambiguous, elicit domain clarity in focused stages:
|
|
71
|
+
1. **Stage 1 (System Context):** Identify Actors (human personas) and External Systems (SaaS, payment gateways).
|
|
72
|
+
2. **Stage 2 (Aggregates & Boundaries):** Identify high-cohesion Aggregates and Root Entities.
|
|
73
|
+
3. **Stage 3 (Lifecycle States & Commands):** Map out valid states and actions that transition between them.
|
|
74
|
+
4. **Stage 4 (Invariants & Business Rules):** Identify guard constraints (e.g., *"Cannot borrow if unpaid fees > $10"*).
|
|
75
|
+
|
|
76
|
+
### Step 2: Author the Open ADM Model
|
|
77
|
+
Save the domain model as a valid Open ADM JSON file in the project (e.g., `specs/<domain>.adm.json` or `<domain>.adm.json`), referencing the canonical JSON schema and root envelope:
|
|
78
|
+
|
|
79
|
+
```json
|
|
80
|
+
{
|
|
81
|
+
"$schema": "https://spica.simway.io/schema/adm.json",
|
|
82
|
+
"specVersion": "0.0.0",
|
|
83
|
+
"author": "Spica Architect",
|
|
84
|
+
"createdAt": "2026-11-15T00:00:00Z",
|
|
85
|
+
"domainName": "OrderFulfillment",
|
|
86
|
+
"systemName": "Order Fulfillment System",
|
|
87
|
+
"systemDescription": "Manages order placement, payment capture, and shipment dispatch.",
|
|
88
|
+
"actors": [
|
|
89
|
+
{ "name": "Customer", "description": "Places orders and submits payment." },
|
|
90
|
+
{ "name": "WarehouseClerk", "description": "Picks items and confirms shipment." }
|
|
91
|
+
],
|
|
92
|
+
"externalSystems": [
|
|
93
|
+
{ "name": "StripeGateway", "description": "Processes credit card payments", "relationship": "Charges cards [HTTPS/REST]" }
|
|
94
|
+
],
|
|
95
|
+
"aggregates": [
|
|
96
|
+
{
|
|
97
|
+
"name": "Order",
|
|
98
|
+
"rootEntity": "Order",
|
|
99
|
+
"states": ["Created", "Paid", "Shipped", "Canceled"],
|
|
100
|
+
"entities": [
|
|
101
|
+
{
|
|
102
|
+
"name": "Order",
|
|
103
|
+
"fields": [
|
|
104
|
+
{ "name": "$id", "type": "string", "required": true },
|
|
105
|
+
{ "name": "totalAmount", "type": "number", "required": true }
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
"commands": [
|
|
110
|
+
{
|
|
111
|
+
"name": "CreateOrder",
|
|
112
|
+
"actor": "Customer",
|
|
113
|
+
"requiredState": "",
|
|
114
|
+
"targetState": "Created",
|
|
115
|
+
"parameters": [{ "name": "totalAmount", "type": "number", "required": true }],
|
|
116
|
+
"isCreation": true
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"name": "MarkPaid",
|
|
120
|
+
"actor": "Customer",
|
|
121
|
+
"requiredState": "Created",
|
|
122
|
+
"targetState": "Paid",
|
|
123
|
+
"parameters": []
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"name": "ShipOrder",
|
|
127
|
+
"actor": "WarehouseClerk",
|
|
128
|
+
"requiredState": "Paid",
|
|
129
|
+
"targetState": "Shipped",
|
|
130
|
+
"parameters": []
|
|
131
|
+
}
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Step 3: Invariant Verification
|
|
139
|
+
|
|
140
|
+
#### Option A: Terminal / CLI Mode (Preferred when terminal tool exists)
|
|
141
|
+
Run the validator (prefers locally or globally installed `spica`, falls back to `npx`):
|
|
142
|
+
```bash
|
|
143
|
+
spica validate <domain>.adm.json
|
|
144
|
+
# or zero-install:
|
|
145
|
+
npx -y @simway/spica validate <domain>.adm.json
|
|
146
|
+
```
|
|
147
|
+
*(Also supports `bunx --bun @simway/spica validate` or `pnpm dlx @simway/spica validate`).*
|
|
148
|
+
- If the CLI reports errors (`E_...`), resolve the exact invariant violation reported by the compiler and re-validate until green.
|
|
149
|
+
- To inspect spec rules offline: run `spica spec` or `spica explain <topic>` (e.g. `spica explain aggregates`).
|
|
150
|
+
|
|
151
|
+
#### Option B: Browser Studio Mode (When CLI / Node is unavailable)
|
|
152
|
+
If operating in an environment without Node/terminal tools (e.g., Python/Go dev container, web chat, air-gapped terminal):
|
|
153
|
+
- Encode the model JSON into a Base64 string.
|
|
154
|
+
- Provide the 1-click preview link:
|
|
155
|
+
`👉 [Open & Validate in Spica Studio](https://spica.simway.io/#spec=<base64>)`
|
|
156
|
+
- Spica Studio runs the full `@simway/spica` engine client-side in the user's browser, providing instant visual feedback and error callouts without local packages.
|
|
157
|
+
|
|
158
|
+
### Step 4: Multi-Lens Projection
|
|
159
|
+
|
|
160
|
+
#### With CLI:
|
|
161
|
+
* **AWS Kiro Agentic Specs (.kiro/specs/):**
|
|
162
|
+
```bash
|
|
163
|
+
spica project-kiro <domain>.adm.json -o .kiro/specs/<feature>
|
|
164
|
+
# or zero-install:
|
|
165
|
+
npx -y @simway/spica project-kiro <domain>.adm.json -o .kiro/specs/<feature>
|
|
166
|
+
```
|
|
167
|
+
* **OpenAPI 3.0 Contract:**
|
|
168
|
+
```bash
|
|
169
|
+
spica project-openapi <domain>.adm.json -o openapi.json
|
|
170
|
+
# or zero-install:
|
|
171
|
+
npx -y @simway/spica project-openapi <domain>.adm.json -o openapi.json
|
|
172
|
+
```
|
|
173
|
+
* **Generate 1-Click Interactive Browser Link:**
|
|
174
|
+
```bash
|
|
175
|
+
spica share <domain>.adm.json
|
|
176
|
+
# or zero-install:
|
|
177
|
+
npx -y @simway/spica share <domain>.adm.json
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### Without CLI:
|
|
181
|
+
- Users open the Spica Studio link (`https://spica.simway.io/#spec=...`) to download `.kiro/specs/`, `openapi.json`, or Mermaid diagram SVGs directly via the web UI.
|
|
182
|
+
|
|
183
|
+
### Step 5: Deliver Output to Human
|
|
184
|
+
Always present the user with:
|
|
185
|
+
1. Summary of validated aggregates, states, and commands.
|
|
186
|
+
2. File paths of generated `.kiro/specs/` or `openapi.json`.
|
|
187
|
+
3. The clickable live preview URL:
|
|
188
|
+
`👉 [Open in Spica Studio](https://spica.simway.io/#spec=...)` so they can visually inspect the Mermaid diagram and C4 context in their browser.
|