@sublang/spex 0.1.0
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/LICENSE +201 -0
- package/README.md +77 -0
- package/dist/append-agent-specs.d.ts +10 -0
- package/dist/append-agent-specs.js +106 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +27 -0
- package/dist/copy-templates.d.ts +14 -0
- package/dist/copy-templates.js +60 -0
- package/dist/create-specs-structure.d.ts +7 -0
- package/dist/create-specs-structure.js +38 -0
- package/dist/resolve-base.d.ts +8 -0
- package/dist/resolve-base.js +40 -0
- package/dist/scaffold.d.ts +5 -0
- package/dist/scaffold.js +24 -0
- package/package.json +34 -0
- package/scaffold/agent-specs.txt +5 -0
- package/scaffold/specs/decisions/000-spec-structure-format.md +107 -0
- package/scaffold/specs/items/dev/git.md +28 -0
- package/scaffold/specs/items/dev/licensing.md +38 -0
- package/scaffold/specs/items/test/licensing.md +20 -0
- package/scaffold/specs/items/user/.gitkeep +1 -0
- package/scaffold/specs/iterations/000-spdx-headers.md +55 -0
- package/scaffold/specs/map.md +48 -0
- package/scaffold/specs/meta.md +145 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# spex
|
|
5
|
+
|
|
6
|
+
[](https://www.npmjs.com/package/@sublang/spex)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](https://github.com/sublang-ai/spex/actions/workflows/ci.yml)
|
|
9
|
+
|
|
10
|
+
*The essential spec layer AI agents need to build software reliably.*
|
|
11
|
+
|
|
12
|
+
Scaffolds a `specs/` directory so AI coding agents can read and follow
|
|
13
|
+
your project's requirements and design.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install -g @sublang/spex
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Or run once without installing:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npx @sublang/spex scaffold
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
spex scaffold
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This creates:
|
|
34
|
+
|
|
35
|
+
- **`specs/`** — directories and starter templates for writing behavioral
|
|
36
|
+
specs, decision records, and iteration plans
|
|
37
|
+
- **`CLAUDE.md` / `AGENTS.md`** — instructions that tell AI agents (Claude,
|
|
38
|
+
Codex, etc.) to read and follow the specs before writing code
|
|
39
|
+
|
|
40
|
+
See `specs/decisions/000-spec-structure-format.md` for the spec format and naming conventions.
|
|
41
|
+
|
|
42
|
+
Idempotency: Rerunning is safe — existing files and directories are skipped.
|
|
43
|
+
|
|
44
|
+
**Try it:** review the sample iteration `specs/iterations/000-spdx-headers.md`, update the copyright text, then prompt your AI coding agent:
|
|
45
|
+
|
|
46
|
+
```text
|
|
47
|
+
Complete Iteration #0
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Workflow
|
|
51
|
+
|
|
52
|
+
Spex does *not* enforce a heavyweight workflow.
|
|
53
|
+
We believe spec-driven development is a flexible combination of a few primitives.
|
|
54
|
+
|
|
55
|
+
1. **Make Decisions** — Discuss requirements, architecture, and design with AI agents. Let AI generate and review decision records in `specs/decisions/`.
|
|
56
|
+
2. **Plan Iterations** — Break down work into tasks with AI agents. Let AI generate and review iteration records in `specs/iterations/`.
|
|
57
|
+
3. **Agents Execute** — Let AI agents complete the tasks autonomously. They generate code and update `specs/items/`.
|
|
58
|
+
|
|
59
|
+
Then loop back to the next decision or iteration.
|
|
60
|
+
|
|
61
|
+
## Requirements
|
|
62
|
+
|
|
63
|
+
- Node.js >= 20
|
|
64
|
+
- Git (optional, used for repo root detection)
|
|
65
|
+
|
|
66
|
+
## Contributing
|
|
67
|
+
|
|
68
|
+
We welcome contributions of all kinds. If you'd like to help:
|
|
69
|
+
|
|
70
|
+
- 🌟 Star our repo if you find spex useful.
|
|
71
|
+
- [Open an issue](https://github.com/sublang-ai/spex/issues) for bugs or feature requests.
|
|
72
|
+
- [Open a PR](https://github.com/sublang-ai/spex/pulls) for fixes or improvements.
|
|
73
|
+
- Discuss on [Discord](https://discord.gg/XxTPjNqy9g) for support or new ideas.
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
[Apache-2.0](LICENSE)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Read scaffold/agent-specs.txt and process CLAUDE.md and AGENTS.md
|
|
3
|
+
* at basePath.
|
|
4
|
+
*
|
|
5
|
+
* SCAF-10: when neither exists, both are created; when only one
|
|
6
|
+
* exists, only that file is updated. Section replacement uses
|
|
7
|
+
* case-sensitive match on "## Specs (Source of Truth)".
|
|
8
|
+
* SCAF-5: replace in place or skip when identical.
|
|
9
|
+
*/
|
|
10
|
+
export declare function appendAgentSpecs(basePath: string): void;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { getScaffoldDir } from "./copy-templates.js";
|
|
6
|
+
const SECTION_HEADING = "## Specs (Source of Truth)";
|
|
7
|
+
const AGENT_FILES = ["CLAUDE.md", "AGENTS.md"];
|
|
8
|
+
function escapeRegExp(s) {
|
|
9
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Extract the specs section from content: from the heading to the
|
|
13
|
+
* next h2 heading or end of file.
|
|
14
|
+
* Returns [start, end] character offsets, or null if not found.
|
|
15
|
+
*/
|
|
16
|
+
function findSection(content) {
|
|
17
|
+
// Match only as a real H2 heading at start of a line (or start of file).
|
|
18
|
+
// Handle both LF and CRLF line endings.
|
|
19
|
+
const pattern = new RegExp(`(?:^|\\r?\\n)${escapeRegExp(SECTION_HEADING)}(?:\\r?\\n|$)`);
|
|
20
|
+
const match = pattern.exec(content);
|
|
21
|
+
if (!match)
|
|
22
|
+
return null;
|
|
23
|
+
// Start at the heading itself, not the preceding line ending
|
|
24
|
+
const matchText = match[0];
|
|
25
|
+
let idx = match.index;
|
|
26
|
+
if (matchText.startsWith("\r\n"))
|
|
27
|
+
idx += 2;
|
|
28
|
+
else if (matchText.startsWith("\n"))
|
|
29
|
+
idx += 1;
|
|
30
|
+
// Find the next ## heading after the section heading line
|
|
31
|
+
const afterHeading = idx + SECTION_HEADING.length;
|
|
32
|
+
const nextH2Match = content.slice(afterHeading).match(/\r?\n## /);
|
|
33
|
+
const end = nextH2Match?.index !== undefined
|
|
34
|
+
? afterHeading + nextH2Match.index
|
|
35
|
+
: content.length;
|
|
36
|
+
return [idx, end];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Process a single agent file: replace section in place, append,
|
|
40
|
+
* or create.
|
|
41
|
+
*
|
|
42
|
+
* Returns: "created" | "updated" | "skipped" | null (file absent)
|
|
43
|
+
*/
|
|
44
|
+
function processFile(filePath, specsContent, fileExists, shouldCreate) {
|
|
45
|
+
if (!fileExists) {
|
|
46
|
+
if (shouldCreate) {
|
|
47
|
+
writeFileSync(filePath, specsContent);
|
|
48
|
+
return "created";
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const existing = readFileSync(filePath, "utf-8");
|
|
53
|
+
const section = findSection(existing);
|
|
54
|
+
if (section !== null) {
|
|
55
|
+
const [start, end] = section;
|
|
56
|
+
const currentSection = existing.slice(start, end);
|
|
57
|
+
// Trim trailing whitespace for comparison
|
|
58
|
+
if (currentSection.trimEnd() === specsContent.trimEnd()) {
|
|
59
|
+
return "skipped";
|
|
60
|
+
}
|
|
61
|
+
const updated = existing.slice(0, start) + specsContent + existing.slice(end);
|
|
62
|
+
writeFileSync(filePath, updated);
|
|
63
|
+
return "updated";
|
|
64
|
+
}
|
|
65
|
+
// Heading absent — append
|
|
66
|
+
const separator = existing.endsWith("\n") ? "\n" : "\n\n";
|
|
67
|
+
writeFileSync(filePath, existing + separator + specsContent);
|
|
68
|
+
return "updated";
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Read scaffold/agent-specs.txt and process CLAUDE.md and AGENTS.md
|
|
72
|
+
* at basePath.
|
|
73
|
+
*
|
|
74
|
+
* SCAF-10: when neither exists, both are created; when only one
|
|
75
|
+
* exists, only that file is updated. Section replacement uses
|
|
76
|
+
* case-sensitive match on "## Specs (Source of Truth)".
|
|
77
|
+
* SCAF-5: replace in place or skip when identical.
|
|
78
|
+
*/
|
|
79
|
+
export function appendAgentSpecs(basePath) {
|
|
80
|
+
const scaffoldDir = getScaffoldDir();
|
|
81
|
+
const specsContent = readFileSync(join(scaffoldDir, "agent-specs.txt"), "utf-8");
|
|
82
|
+
const presence = AGENT_FILES.map((f) => existsSync(join(basePath, f)));
|
|
83
|
+
const neitherExists = presence.every((p) => !p);
|
|
84
|
+
for (let i = 0; i < AGENT_FILES.length; i++) {
|
|
85
|
+
const fileName = AGENT_FILES[i];
|
|
86
|
+
const filePath = join(basePath, fileName);
|
|
87
|
+
const fileExists = presence[i];
|
|
88
|
+
const shouldCreate = neitherExists;
|
|
89
|
+
const result = processFile(filePath, specsContent, fileExists, shouldCreate);
|
|
90
|
+
switch (result) {
|
|
91
|
+
case "created":
|
|
92
|
+
console.log(` ${fileName} (created)`);
|
|
93
|
+
break;
|
|
94
|
+
case "updated":
|
|
95
|
+
console.log(` ${fileName} (updated)`);
|
|
96
|
+
break;
|
|
97
|
+
case "skipped":
|
|
98
|
+
console.log(` ${fileName} (skipped)`);
|
|
99
|
+
break;
|
|
100
|
+
case null:
|
|
101
|
+
// File absent and not creating — no output
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=append-agent-specs.js.map
|
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
4
|
+
import { scaffold } from "./scaffold.js";
|
|
5
|
+
const USAGE = `Usage: spex <command> [options]
|
|
6
|
+
|
|
7
|
+
Commands:
|
|
8
|
+
scaffold [<path>] Create specs directory structure`;
|
|
9
|
+
function main() {
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const command = args[0];
|
|
12
|
+
if (!command || command === "--help" || command === "-h") {
|
|
13
|
+
console.log(USAGE);
|
|
14
|
+
process.exit(0);
|
|
15
|
+
}
|
|
16
|
+
switch (command) {
|
|
17
|
+
case "scaffold":
|
|
18
|
+
scaffold(args[1]);
|
|
19
|
+
break;
|
|
20
|
+
default:
|
|
21
|
+
console.error(`Unknown command: ${command}\n`);
|
|
22
|
+
console.error(USAGE);
|
|
23
|
+
process.exit(1);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
main();
|
|
27
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the bundled scaffold/ directory path.
|
|
3
|
+
*
|
|
4
|
+
* SCAF-9: navigate from dist/ output directory up to the package
|
|
5
|
+
* root and return the scaffold/ directory path.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getScaffoldDir(): string;
|
|
8
|
+
/**
|
|
9
|
+
* Copy bundled template files from scaffold/specs/ to target specs/.
|
|
10
|
+
*
|
|
11
|
+
* SCAF-8: recursively copies files; existing files are not overwritten.
|
|
12
|
+
* SCAF-9: resolves scaffold/ from the dist/ output directory.
|
|
13
|
+
*/
|
|
14
|
+
export declare function copyTemplates(basePath: string): void;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
import { copyFileSync, existsSync, readdirSync, statSync } from "node:fs";
|
|
4
|
+
import { dirname, join, posix, resolve } from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the bundled scaffold/ directory path.
|
|
8
|
+
*
|
|
9
|
+
* SCAF-9: navigate from dist/ output directory up to the package
|
|
10
|
+
* root and return the scaffold/ directory path.
|
|
11
|
+
*/
|
|
12
|
+
export function getScaffoldDir() {
|
|
13
|
+
const thisFile = fileURLToPath(import.meta.url);
|
|
14
|
+
// thisFile is in dist/ — go up one level to package root.
|
|
15
|
+
const packageRoot = dirname(dirname(thisFile));
|
|
16
|
+
return resolve(packageRoot, "scaffold");
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Recursively copy files from srcDir to destDir.
|
|
20
|
+
* Files that already exist at the destination are not overwritten (SCAF-8).
|
|
21
|
+
* Prints status for each file relative to relRoot.
|
|
22
|
+
*/
|
|
23
|
+
function copyRecursive(srcDir, destDir, relRoot) {
|
|
24
|
+
const entries = readdirSync(srcDir);
|
|
25
|
+
for (const entry of entries) {
|
|
26
|
+
if (entry === ".DS_Store")
|
|
27
|
+
continue;
|
|
28
|
+
const srcPath = join(srcDir, entry);
|
|
29
|
+
const destPath = join(destDir, entry);
|
|
30
|
+
const relPath = posix.join(relRoot, entry);
|
|
31
|
+
if (statSync(srcPath).isDirectory()) {
|
|
32
|
+
copyRecursive(srcPath, destPath, relPath);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
if (existsSync(destPath)) {
|
|
36
|
+
console.log(` ${relPath} (already exists)`);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
copyFileSync(srcPath, destPath);
|
|
40
|
+
console.log(` ${relPath}`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Copy bundled template files from scaffold/specs/ to target specs/.
|
|
47
|
+
*
|
|
48
|
+
* SCAF-8: recursively copies files; existing files are not overwritten.
|
|
49
|
+
* SCAF-9: resolves scaffold/ from the dist/ output directory.
|
|
50
|
+
*/
|
|
51
|
+
export function copyTemplates(basePath) {
|
|
52
|
+
const scaffoldDir = getScaffoldDir();
|
|
53
|
+
const srcSpecs = join(scaffoldDir, "specs");
|
|
54
|
+
const destSpecs = join(basePath, "specs");
|
|
55
|
+
if (!existsSync(srcSpecs)) {
|
|
56
|
+
throw new Error(`Bundled scaffold/specs/ not found: ${srcSpecs}`);
|
|
57
|
+
}
|
|
58
|
+
copyRecursive(srcSpecs, destSpecs, "specs");
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=copy-templates.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
import { existsSync, mkdirSync, statSync } from "node:fs";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
/**
|
|
6
|
+
* SCAF-7 directories under specs/.
|
|
7
|
+
*/
|
|
8
|
+
const DIRS = [
|
|
9
|
+
"specs",
|
|
10
|
+
"specs/decisions",
|
|
11
|
+
"specs/iterations",
|
|
12
|
+
"specs/items",
|
|
13
|
+
"specs/items/user",
|
|
14
|
+
"specs/items/dev",
|
|
15
|
+
"specs/items/test",
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* Create the specs directory structure under basePath.
|
|
19
|
+
*
|
|
20
|
+
* SCAF-7: creates specs/ with subdirectories.
|
|
21
|
+
* SCAF-4: skips existing directories with "(already exists)".
|
|
22
|
+
*/
|
|
23
|
+
export function createSpecsStructure(basePath) {
|
|
24
|
+
for (const dir of DIRS) {
|
|
25
|
+
const target = join(basePath, dir);
|
|
26
|
+
if (existsSync(target)) {
|
|
27
|
+
if (!statSync(target).isDirectory()) {
|
|
28
|
+
throw new Error(`${dir} exists but is not a directory: ${target}`);
|
|
29
|
+
}
|
|
30
|
+
console.log(` ${dir}/ (already exists)`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
mkdirSync(target);
|
|
34
|
+
console.log(` ${dir}/`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=create-specs-structure.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolve the base path for scaffold output.
|
|
3
|
+
*
|
|
4
|
+
* SCAF-1: explicit path (must exist and be a directory)
|
|
5
|
+
* SCAF-2: no path, inside git repo → repo root
|
|
6
|
+
* SCAF-3: no path, outside git repo → cwd
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveBase(pathArg?: string): string;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
import { execSync } from "node:child_process";
|
|
4
|
+
import { statSync } from "node:fs";
|
|
5
|
+
import { resolve } from "node:path";
|
|
6
|
+
/**
|
|
7
|
+
* Resolve the base path for scaffold output.
|
|
8
|
+
*
|
|
9
|
+
* SCAF-1: explicit path (must exist and be a directory)
|
|
10
|
+
* SCAF-2: no path, inside git repo → repo root
|
|
11
|
+
* SCAF-3: no path, outside git repo → cwd
|
|
12
|
+
*/
|
|
13
|
+
export function resolveBase(pathArg) {
|
|
14
|
+
if (pathArg !== undefined) {
|
|
15
|
+
const abs = resolve(pathArg);
|
|
16
|
+
let stat;
|
|
17
|
+
try {
|
|
18
|
+
stat = statSync(abs);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw new Error(`Path does not exist: ${abs}`);
|
|
22
|
+
}
|
|
23
|
+
if (!stat.isDirectory()) {
|
|
24
|
+
throw new Error(`Path is not a directory: ${abs}`);
|
|
25
|
+
}
|
|
26
|
+
return abs;
|
|
27
|
+
}
|
|
28
|
+
// No explicit path — try git repo root, fall back to cwd.
|
|
29
|
+
try {
|
|
30
|
+
const root = execSync("git rev-parse --show-toplevel", {
|
|
31
|
+
encoding: "utf-8",
|
|
32
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
33
|
+
}).trim();
|
|
34
|
+
return root;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return process.cwd();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=resolve-base.js.map
|
package/dist/scaffold.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
3
|
+
import { appendAgentSpecs } from "./append-agent-specs.js";
|
|
4
|
+
import { copyTemplates } from "./copy-templates.js";
|
|
5
|
+
import { createSpecsStructure } from "./create-specs-structure.js";
|
|
6
|
+
import { resolveBase } from "./resolve-base.js";
|
|
7
|
+
/**
|
|
8
|
+
* Entry point for the scaffold subcommand.
|
|
9
|
+
* @param pathArg - Optional explicit target path
|
|
10
|
+
*/
|
|
11
|
+
export function scaffold(pathArg) {
|
|
12
|
+
try {
|
|
13
|
+
const basePath = resolveBase(pathArg);
|
|
14
|
+
createSpecsStructure(basePath);
|
|
15
|
+
copyTemplates(basePath);
|
|
16
|
+
appendAgentSpecs(basePath);
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
20
|
+
console.error(`spex scaffold: ${msg}`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=scaffold.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sublang/spex",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Spec framework CLI",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/sublang-ai/spex.git"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"spex": "dist/cli.js"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist/**/*.js",
|
|
16
|
+
"!dist/**/*.test.js",
|
|
17
|
+
"dist/**/*.d.ts",
|
|
18
|
+
"!dist/**/*.test.d.ts",
|
|
19
|
+
"scaffold/"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsc",
|
|
23
|
+
"prepublishOnly": "npm run build && npm test",
|
|
24
|
+
"test": "node scripts/run-tests.cjs",
|
|
25
|
+
"test:integration": "node scripts/run-tests.cjs \"\\.integration\\.test\\.js$\""
|
|
26
|
+
},
|
|
27
|
+
"engines": {
|
|
28
|
+
"node": ">=20"
|
|
29
|
+
},
|
|
30
|
+
"devDependencies": {
|
|
31
|
+
"typescript": "^5.8.0",
|
|
32
|
+
"@types/node": "^22.0.0"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
## Specs (Source of Truth)
|
|
2
|
+
|
|
3
|
+
- Canonical specs live in `specs/`. Start with `specs/map.md` for a quick-reference index of all spec files.
|
|
4
|
+
- Before making changes or suggestions in an area that has a spec, read the relevant spec file(s) first and follow them.
|
|
5
|
+
- If unsure which spec applies, search `specs/` and propose the most relevant file(s) before proceeding.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# DR-000: Spec Structure and Format
|
|
5
|
+
|
|
6
|
+
## Status
|
|
7
|
+
|
|
8
|
+
Accepted
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
Specifications (specs) need a standardized format and structure to support iterative development and collaboration between AI and humans.
|
|
13
|
+
|
|
14
|
+
## Decision
|
|
15
|
+
|
|
16
|
+
### Elements
|
|
17
|
+
|
|
18
|
+
Spex organizes specs around three essential elements of software development:
|
|
19
|
+
|
|
20
|
+
- **Decisions**. The choices made in product and system *design*.
|
|
21
|
+
- **Iterations**. The incremental plans for *implementation*.
|
|
22
|
+
- **Requirements**. The *behaviors* and *constraints* of the product and system.
|
|
23
|
+
|
|
24
|
+
### Forms
|
|
25
|
+
|
|
26
|
+
Spex uses two forms of specs to balance unification and flexibility.
|
|
27
|
+
|
|
28
|
+
- **Records** must follow specified formats and may use free-form content within those formats.
|
|
29
|
+
Decisions and iterations are stored as records.
|
|
30
|
+
- Decision records (DRs) follow the ADR (Architectural Decision Record) format [[1]].
|
|
31
|
+
- Iteration records (IRs) contain four sections: Goal, Deliverables, Tasks, and Acceptance criteria.
|
|
32
|
+
- **Items** must follow the GEARS pattern [[2]] to specify requirements and constraints.
|
|
33
|
+
Each item file must include an intent statement.
|
|
34
|
+
|
|
35
|
+
### Organization
|
|
36
|
+
|
|
37
|
+
Spex creates the default `specs/` directory under the repo root, with the following subdirectories and files.
|
|
38
|
+
|
|
39
|
+
| Path | Content | File Naming |
|
|
40
|
+
| --------- | ------- | ------ |
|
|
41
|
+
| `decisions/` | DRs | \<NNN\>-\<kebab-case\>.md |
|
|
42
|
+
| `iterations/` | IRs | \<NNN\>-\<kebab-case\>.md |
|
|
43
|
+
| `items/` | item files | [\<path\>/]\<kebab-case\>.md |
|
|
44
|
+
| `map.md` | spec index for navigation | - |
|
|
45
|
+
| `meta.md` | the spec of specs | - |
|
|
46
|
+
|
|
47
|
+
### Item groups
|
|
48
|
+
|
|
49
|
+
Item files are grouped into three subdirectories under `items/`:
|
|
50
|
+
|
|
51
|
+
| Subdirectory | Purpose |
|
|
52
|
+
| ----- | ------- |
|
|
53
|
+
| `user/` | What the system does. User-visible behavior. |
|
|
54
|
+
| `dev/` | How the system is built. Not user-visible. |
|
|
55
|
+
| `test/` | Acceptance testing. Each item cites the user or dev item it tests. |
|
|
56
|
+
|
|
57
|
+
### Item syntax
|
|
58
|
+
|
|
59
|
+
A spec item must follow the GEARS syntax:
|
|
60
|
+
|
|
61
|
+
```text
|
|
62
|
+
[Where <static precondition(s)>] [While <stateful precondition(s)>] [When <trigger>] The <subject> shall <behavior>.
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Keyword | Purpose |
|
|
66
|
+
| ------ | ------- |
|
|
67
|
+
| Where | Static preconditions (features, config) |
|
|
68
|
+
| While | Stateful preconditions (runtime state) |
|
|
69
|
+
| When | Trigger event (at most one) |
|
|
70
|
+
| shall | Required behavior |
|
|
71
|
+
|
|
72
|
+
For test specs, Given-When-Then maps to: Given → Where+While, When → When, Then → shall.
|
|
73
|
+
|
|
74
|
+
### Spec packages
|
|
75
|
+
|
|
76
|
+
A spec package is a coherent set of spec items for a *single* intent.
|
|
77
|
+
It is the basic unit for spec composition, reuse, and extension.
|
|
78
|
+
|
|
79
|
+
A spec package consists of one to three coordinated item files sharing the same relative path and basename.
|
|
80
|
+
The item files are located in `user/`, `dev/`, or `test/` according to which [groups](#item-groups) they belong to.
|
|
81
|
+
|
|
82
|
+
For example, a spec package for generating short URLs may be named `gen-url` and consist of:
|
|
83
|
+
|
|
84
|
+
- `items/user/signing/gen-url.md` for user-facing behaviors (e.g., basic operations, URL format)
|
|
85
|
+
- `items/dev/signing/gen-url.md` for internal-implementation behaviors (e.g., algorithms)
|
|
86
|
+
- `items/test/signing/gen-url.md` for tests covering the corresponding user and dev items
|
|
87
|
+
|
|
88
|
+
Here, `signing/` is a local collection of related spec packages for development convenience.
|
|
89
|
+
|
|
90
|
+
`map.md` organizes item files by package.
|
|
91
|
+
|
|
92
|
+
### Citations
|
|
93
|
+
|
|
94
|
+
DRs and items are persistent and may cite each other.
|
|
95
|
+
IRs may be temporary and must not be cited by DRs or items.
|
|
96
|
+
`map.md` may cite IRs, as it indexes all spec files and is kept in sync as files change.
|
|
97
|
+
|
|
98
|
+
## Consequences
|
|
99
|
+
|
|
100
|
+
- Consistent structure and format across development cycles
|
|
101
|
+
- Clear positions of directories and files
|
|
102
|
+
- Flexible expression of design and implementation
|
|
103
|
+
|
|
104
|
+
## References
|
|
105
|
+
|
|
106
|
+
[1]: https://github.com/npryce/adr-tools "ADR Tools"
|
|
107
|
+
[2]: https://sublang.ai/ref/gears-ai-ready-spec-syntax "GEARS: AI-Ready Spec Syntax"
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# GIT: Git Workflow
|
|
5
|
+
|
|
6
|
+
## Intent
|
|
7
|
+
|
|
8
|
+
This spec defines git workflow rules for the project.
|
|
9
|
+
|
|
10
|
+
## Commits
|
|
11
|
+
|
|
12
|
+
### GIT-1
|
|
13
|
+
|
|
14
|
+
When preparing a commit, the AI agent shall verify `user.name` and `user.email` are configured.
|
|
15
|
+
|
|
16
|
+
### GIT-2
|
|
17
|
+
|
|
18
|
+
When writing a commit message subject, the commit message shall use `<type>(<scope>)<!>: <subject>` format, where `<scope>` is optional, `!` is included for breaking changes, `<type>` is one of `feat|fix|docs|style|refactor|test|ci|build|perf|chore`, and `<subject>` is imperative, <=50 chars, with no trailing period.
|
|
19
|
+
|
|
20
|
+
### GIT-3
|
|
21
|
+
|
|
22
|
+
Where a commit message includes a body, when writing the body, the commit body shall explain what and why rather than how, wrap at 72 chars, and use bullets if clearer.
|
|
23
|
+
|
|
24
|
+
### GIT-4
|
|
25
|
+
|
|
26
|
+
When AI assists in coding or authoring, the commit message shall include a `Co-authored-by` trailer in the format `<model> (<role>) <email>`, where `<role>` is one of `coder|reviewer|maintainer` and `<email>` is `cligent@sublang.ai`.
|
|
27
|
+
|
|
28
|
+
Example: `Co-authored-by: GPT-5.2-Codex (coder) <cligent@sublang.ai>`
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# LIC: Licensing Headers
|
|
5
|
+
|
|
6
|
+
## Intent
|
|
7
|
+
|
|
8
|
+
This spec defines SPDX header requirements for files included in the project.
|
|
9
|
+
|
|
10
|
+
## Scope
|
|
11
|
+
|
|
12
|
+
### Exclusions
|
|
13
|
+
|
|
14
|
+
The following files are out of scope:
|
|
15
|
+
|
|
16
|
+
- No comment syntax: e.g., JSON, binaries
|
|
17
|
+
- Config: e.g., `.gitignore`, `.editorconfig`, `**/settings.json`, `AGENTS.md`, `.github/workflows/ci.yml`, lock files
|
|
18
|
+
- Generated/vendor: e.g., `dist/`, `node_modules/`, vendor directories
|
|
19
|
+
- License/legal documents
|
|
20
|
+
|
|
21
|
+
### License File Detection
|
|
22
|
+
|
|
23
|
+
Recognized patterns at project root:
|
|
24
|
+
|
|
25
|
+
- `LICENSE`, `LICENSE.txt`, `LICENSE.md`, `COPYING`
|
|
26
|
+
- `LICENSE-CONTENT`, `LICENSE-APACHE`, etc. (named variants)
|
|
27
|
+
- `LICENCE`, `LICENCE.txt` (British spelling)
|
|
28
|
+
- `LICENSES/` folder (REUSE convention)
|
|
29
|
+
|
|
30
|
+
## Headers
|
|
31
|
+
|
|
32
|
+
### LIC-1
|
|
33
|
+
|
|
34
|
+
Where the file has comment syntax and is not excluded by [Exclusions](#exclusions), while the file is git-tracked or `git add`-able, when preparing the file for inclusion in the repo, the file shall include `SPDX-FileCopyrightText` in its first comment block after any shebang.
|
|
35
|
+
|
|
36
|
+
### LIC-2
|
|
37
|
+
|
|
38
|
+
Where the file has comment syntax, is not excluded by [Exclusions](#exclusions), and one or more project-root license files match [License File Detection](#license-file-detection), while the file is git-tracked or `git add`-able, when preparing the file for inclusion in the repo, the file shall include `SPDX-License-Identifier` in its first comment block after any shebang.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# LIC: Licensing Headers
|
|
5
|
+
|
|
6
|
+
## Intent
|
|
7
|
+
|
|
8
|
+
This spec defines acceptance tests for SPDX copyright and license headers.
|
|
9
|
+
|
|
10
|
+
## Header Checks
|
|
11
|
+
|
|
12
|
+
### LIC-3
|
|
13
|
+
Verifies: [LIC-1](../dev/licensing.md#lic-1)
|
|
14
|
+
|
|
15
|
+
Where the file has comment syntax and is not [excluded](../dev/licensing.md#exclusions), while git-tracked or `git add`-able, when checking its first comment block after any shebang, the file shall contain `SPDX-FileCopyrightText`.
|
|
16
|
+
|
|
17
|
+
### LIC-4
|
|
18
|
+
Verifies: [LIC-2](../dev/licensing.md#lic-2)
|
|
19
|
+
|
|
20
|
+
Where the file has comment syntax, is not [excluded](../dev/licensing.md#exclusions), and a [license file](../dev/licensing.md#license-file-detection) exists at project root, while git-tracked or `git add`-able, when checking its first comment block after any shebang, the file shall contain `SPDX-License-Identifier`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# IR-000: SPDX Headers
|
|
5
|
+
|
|
6
|
+
## Goal
|
|
7
|
+
|
|
8
|
+
Add SPDX headers (license and copyright info) to applicable files.
|
|
9
|
+
|
|
10
|
+
## Deliverables
|
|
11
|
+
|
|
12
|
+
- [x] Add SPDX headers to applicable files missing them
|
|
13
|
+
- [ ] Document header format in a dev spec
|
|
14
|
+
|
|
15
|
+
## Tasks
|
|
16
|
+
|
|
17
|
+
1. **Detect license file(s)** at project root; skip license line if absent
|
|
18
|
+
- Single license: `LICENSE`, `LICENSE.txt`, `LICENSE.md`, `COPYING`
|
|
19
|
+
- Named variants: `LICENSE-CONTENT`, `LICENSE-APACHE`, etc.
|
|
20
|
+
- British spelling: `LICENCE`, `LICENCE.txt`
|
|
21
|
+
- Multiple licenses: `LICENSES/` folder (REUSE convention)
|
|
22
|
+
|
|
23
|
+
2. **Identify applicable files** according to the license(s): git-tracked or `git add`-able files with comment syntax. Excludes:
|
|
24
|
+
- No comment syntax: e.g., JSON, binaries
|
|
25
|
+
- Config: e.g., `.gitignore`, `.editorconfig`, `**/settings.json`, `AGENTS.md`, `.github/workflows/ci.yml`, lock files
|
|
26
|
+
- Generated/vendor: e.g., `dist/`, `node_modules/`
|
|
27
|
+
- License/legal documents
|
|
28
|
+
|
|
29
|
+
3. **Add headers** in the first comment block (after shebang if present), using appropriate comment syntax per file type
|
|
30
|
+
|
|
31
|
+
4. **Document format** in a dev spec according to the license(s). E.g.:
|
|
32
|
+
|
|
33
|
+
> **Source code** (including specs):
|
|
34
|
+
>
|
|
35
|
+
> ```typescript
|
|
36
|
+
> // SPDX-License-Identifier: Apache-2.0
|
|
37
|
+
> // SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai>
|
|
38
|
+
> ```
|
|
39
|
+
>
|
|
40
|
+
> ```markdown
|
|
41
|
+
> <!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
42
|
+
> <!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
43
|
+
> ```
|
|
44
|
+
>
|
|
45
|
+
> **Contents** (README, docs, blogs, etc.):
|
|
46
|
+
>
|
|
47
|
+
> ```markdown
|
|
48
|
+
> <!-- SPDX-License-Identifier: CC-BY-SA-4.0 -->
|
|
49
|
+
> <!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
50
|
+
> ```
|
|
51
|
+
|
|
52
|
+
## Acceptance criteria
|
|
53
|
+
|
|
54
|
+
- All source files have SPDX-FileCopyrightText header ([LIC-3](../items/test/licensing.md#lic-3))
|
|
55
|
+
- Files have SPDX-License-Identifier if a license file exists ([LIC-4](../items/test/licensing.md#lic-4))
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# Spec Map
|
|
5
|
+
|
|
6
|
+
Quick-reference index for locating spec files.
|
|
7
|
+
Spec items are the source of truth.
|
|
8
|
+
Code can be inconsistent with specs during development.
|
|
9
|
+
|
|
10
|
+
## Layout
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
decisions/ Decision records (DRs)
|
|
14
|
+
iterations/ Iteration records (IRs)
|
|
15
|
+
items/ Spec item files
|
|
16
|
+
user/ User-visible behavior
|
|
17
|
+
dev/ Implementation requirements
|
|
18
|
+
test/ Acceptance testing
|
|
19
|
+
map.md This index
|
|
20
|
+
meta.md The spec of specs
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Decisions
|
|
24
|
+
|
|
25
|
+
| ID | File | Summary |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| DR-000 | [000-spec-structure-format.md](decisions/000-spec-structure-format.md) | Spec structure, format, and naming conventions |
|
|
28
|
+
|
|
29
|
+
## Iterations
|
|
30
|
+
|
|
31
|
+
| ID | File | Goal |
|
|
32
|
+
| --- | --- | --- |
|
|
33
|
+
| IR-000 | [000-spdx-headers.md](iterations/000-spdx-headers.md) | Add SPDX headers to applicable files |
|
|
34
|
+
|
|
35
|
+
## Packages
|
|
36
|
+
|
|
37
|
+
### GIT
|
|
38
|
+
|
|
39
|
+
| Group | File | Summary |
|
|
40
|
+
| --- | --- | --- |
|
|
41
|
+
| dev | [git.md](items/dev/git.md) | Commit message format and AI co-authorship trailers |
|
|
42
|
+
|
|
43
|
+
### LIC
|
|
44
|
+
|
|
45
|
+
| Group | File | Summary |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| dev | [licensing.md](items/dev/licensing.md) | SPDX header requirements and file-scope rules |
|
|
48
|
+
| test | [licensing.md](items/test/licensing.md) | Copyright and license header presence checks |
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<!-- SPDX-License-Identifier: Apache-2.0 -->
|
|
2
|
+
<!-- SPDX-FileCopyrightText: 2026 SubLang International <https://sublang.ai> -->
|
|
3
|
+
|
|
4
|
+
# META: Spec Definition
|
|
5
|
+
|
|
6
|
+
## Intent
|
|
7
|
+
|
|
8
|
+
This spec defines the structure and organization of specifications (specs), per [DR-000](decisions/000-spec-structure-format.md).
|
|
9
|
+
|
|
10
|
+
## Organization
|
|
11
|
+
|
|
12
|
+
### META-1
|
|
13
|
+
|
|
14
|
+
The `specs/` directory shall contain the following subdirectories and files:
|
|
15
|
+
|
|
16
|
+
| Path | Content | File Naming |
|
|
17
|
+
| --------- | ------- | ------ |
|
|
18
|
+
| `decisions/` | Decision records (DRs) | \<NNN\>-\<kebab-case\>.md |
|
|
19
|
+
| `iterations/` | Iteration records (IRs) | \<NNN\>-\<kebab-case\>.md |
|
|
20
|
+
| `items/` | item files | [\<path\>/]\<kebab-case\>.md |
|
|
21
|
+
| `map.md` | spec index for navigation with item files organized by packages | - |
|
|
22
|
+
| `meta.md` | the spec of specs | - |
|
|
23
|
+
|
|
24
|
+
### META-2
|
|
25
|
+
|
|
26
|
+
Item files shall be grouped into three subdirectories under `items/`:
|
|
27
|
+
|
|
28
|
+
| Subdirectory | Purpose |
|
|
29
|
+
| ----- | ------- |
|
|
30
|
+
| `user/` | What the system does. User-visible behavior. |
|
|
31
|
+
| `dev/` | How the system is built. Not user-visible. |
|
|
32
|
+
| `test/` | Acceptance testing. Test items cite the user or dev items they verify. |
|
|
33
|
+
|
|
34
|
+
### META-3
|
|
35
|
+
|
|
36
|
+
Each item file shall include an `## Intent` section stating its purpose.
|
|
37
|
+
|
|
38
|
+
## Record format
|
|
39
|
+
|
|
40
|
+
### META-4
|
|
41
|
+
|
|
42
|
+
Each decision record (DR) shall follow the ADR format [[2]] with the following sections: Status, Context, Decision, and Consequences.
|
|
43
|
+
|
|
44
|
+
### META-5
|
|
45
|
+
|
|
46
|
+
Each iteration record (IR) shall contain the following sections: Goal, Deliverables, Tasks, and Acceptance criteria.
|
|
47
|
+
|
|
48
|
+
## Item syntax
|
|
49
|
+
|
|
50
|
+
### META-6
|
|
51
|
+
|
|
52
|
+
Each spec item shall use the GEARS pattern [[1]]:
|
|
53
|
+
|
|
54
|
+
```text
|
|
55
|
+
[Where <static precondition(s)>] [While <stateful precondition(s)>] [When <trigger>] The <subject> shall <behavior>.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Clauses and punctuation shall follow standard English conventions.
|
|
59
|
+
|
|
60
|
+
| Clause | Purpose | Example |
|
|
61
|
+
| ------ | ------- | ------- |
|
|
62
|
+
| Where | Static preconditions (features, config) | Where debug mode is enabled |
|
|
63
|
+
| While | Stateful preconditions (runtime state) | While the connection is active |
|
|
64
|
+
| When | Trigger event (at most one) | When the user clicks submit |
|
|
65
|
+
| shall | Required behavior | The form shall validate inputs |
|
|
66
|
+
|
|
67
|
+
### META-7
|
|
68
|
+
|
|
69
|
+
Where test cases are expressed by Given-When-Then (GWT), their spec items shall map GWT to GEARS [[1]]:
|
|
70
|
+
|
|
71
|
+
| GWT | Clause |
|
|
72
|
+
| --- | ------ |
|
|
73
|
+
| Given | Where + While |
|
|
74
|
+
| When | When |
|
|
75
|
+
| Then | shall |
|
|
76
|
+
|
|
77
|
+
### META-8
|
|
78
|
+
|
|
79
|
+
Each item shall be self-contained:
|
|
80
|
+
|
|
81
|
+
- It shall have no implicit dependency on sections other than its own subsections.
|
|
82
|
+
- Citations to other specs or shared sections shall be explicit.
|
|
83
|
+
|
|
84
|
+
## Spec packages
|
|
85
|
+
|
|
86
|
+
### META-9
|
|
87
|
+
|
|
88
|
+
A spec package shall consist of one to three coordinated item files sharing the same relative path and basename under `user/`, `dev/`, or `test/`.
|
|
89
|
+
|
|
90
|
+
### META-10
|
|
91
|
+
|
|
92
|
+
A spec package shall have a basename \<kebab-case\>.md unique within `specs/items/`, with a short form \<ALLCAPS\>.
|
|
93
|
+
|
|
94
|
+
Example: `package-management.md` has short form `PKGMGT`.
|
|
95
|
+
|
|
96
|
+
### META-11
|
|
97
|
+
|
|
98
|
+
Each item shall have an ID unique within `specs/`, following \<PACK\>-\<N...\> format (e.g., AUTH-11, URL-3) as a markdown heading for anchor linking.
|
|
99
|
+
|
|
100
|
+
Note: \<PACK\> refers to the short form of the package name.
|
|
101
|
+
|
|
102
|
+
### META-12
|
|
103
|
+
|
|
104
|
+
Item IDs shall not be modified once released; new items shall use higher IDs per package.
|
|
105
|
+
|
|
106
|
+
### META-13
|
|
107
|
+
|
|
108
|
+
A spec package shall define a closed set of subjects and their behaviors for a single intent. The shall clause (see [META-6](#meta-6)) of any item shall only involve subjects and behaviors within its own package.
|
|
109
|
+
|
|
110
|
+
### META-14
|
|
111
|
+
|
|
112
|
+
The precondition and trigger clauses (Where, While, When; see [META-6](#meta-6)) of items shall be allowed to reference subjects and behaviors from other spec packages.
|
|
113
|
+
|
|
114
|
+
### META-15
|
|
115
|
+
|
|
116
|
+
Each spec package shall minimize references to the containing project. When a project-specific reference is essential to a package's intent, it shall be documented in the package's `## Intent` section.
|
|
117
|
+
|
|
118
|
+
## Citation
|
|
119
|
+
|
|
120
|
+
### META-16
|
|
121
|
+
|
|
122
|
+
Citations to specific items shall use relative links with anchors (e.g., `[META-1](meta.md#meta-1)`).
|
|
123
|
+
|
|
124
|
+
### META-17
|
|
125
|
+
|
|
126
|
+
DRs and items shall be allowed to cite each other.
|
|
127
|
+
|
|
128
|
+
### META-18
|
|
129
|
+
|
|
130
|
+
IRs shall not be cited by any spec except `map.md`.
|
|
131
|
+
|
|
132
|
+
### META-19
|
|
133
|
+
|
|
134
|
+
External references in specs shall cite authoritative sources (e.g., official docs) with numbered markers (e.g., `[[1]]`) linked to specific URLs in a `## References` section that shall have no uncited entries.
|
|
135
|
+
|
|
136
|
+
### META-20
|
|
137
|
+
|
|
138
|
+
Each test item shall include one `Verifies:` metadata line immediately below its item ID heading.
|
|
139
|
+
|
|
140
|
+
The `Verifies:` line shall contain one or more comma-separated [citations](#meta-16) to the user or dev items that the test item verifies.
|
|
141
|
+
|
|
142
|
+
## References
|
|
143
|
+
|
|
144
|
+
[1]: https://sublang.ai/ref/gears-ai-ready-spec-syntax "GEARS: AI-Ready Spec Syntax"
|
|
145
|
+
[2]: https://github.com/npryce/adr-tools "ADR Tools"
|