@sddio/cli 0.0.0-stage → 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 benxgao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,143 @@
1
- # Temporary Holding Version
1
+ # @sddio/cli
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Spec-driven development for coding agents, kept in your repo.**
4
+
5
+ `sddio` writes a context layer and a workspace into a project, then hands your agent the first instruction it needs. All of it is plain Markdown committed with your code: what the project requires (`SPEC`), why it's built this way (`ADR`), what's still unresolved (`DISCUSSION`), and what's being worked on (`FLOW`).
6
+
7
+ [Repository](https://github.com/benxgao/sddio) · [FAQ](https://github.com/benxgao/sddio/blob/master/docs/faq.md) · [How it works](https://github.com/benxgao/sddio#readme) · Node ≥ 18 · MIT
8
+
9
+ ![A session writes its decisions into the repository; the next session reads them instead of starting from zero](https://raw.githubusercontent.com/benxgao/sddio/master/assets/how-it-works.svg)
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ npm install --save-dev @sddio/cli
15
+ npx sddio init
16
+ ```
17
+
18
+ Then **paste the prompt `init` prints** into your coding agent. That step is what turns an empty scaffold into project knowledge. The files on their own do nothing.
19
+
20
+ ```text
21
+ ────────────────────────────────────────────────────────────────
22
+ Paste this into your coding agent
23
+ ────────────────────────────────────────────────────────────────
24
+
25
+ Read `.sddio/context/instructions.md` and follow it.
26
+
27
+ This project has just been initialised with sddio. Before any other work:
28
+
29
+ 1. Run the commit check in `.sddio/context/instructions/reconciliation.md`.
30
+ `config.json` has no baseline yet, so the state is `unknown`.
31
+ 2. Bootstrap the workspace as described in `instructions/bootstrap.md`:
32
+ derive the minimum SPEC from the existing code, configuration, tests and
33
+ documentation. Do not ask me for facts the repository already contains.
34
+ 3. Record at least one DISCUSSION for what the repository cannot settle, so
35
+ the workspace opens with an open question and not only with claims.
36
+ 4. Report what you recorded, then set `lastProcessedCommit` to `HEAD` and
37
+ `previousCommit` to `HEAD^` in `.sddio/context/config.json`
38
+ (`null` at a root commit).
39
+
40
+ Then answer this: <your first task>
41
+ ```
42
+
43
+ Finally, commit `.sddio/` and `sddio_workspace/` together with your next change. That's the whole install. `init` writes nothing outside the project, doesn't touch an agent's config directory, and runs no git command.
44
+
45
+ ## What `init` prints
46
+
47
+ | Situation | Prompt | Why |
48
+ | --------- | ------ | --- |
49
+ | First run, files created | bootstrap | the workspace is empty; the agent derives the first SPEC and records the first open question |
50
+ | Only `.sddio/` changed | reconcile | package upgrade; existing knowledge may now be stale |
51
+ | Nothing changed | none | already up to date |
52
+ | `--dry-run` | none | nothing was written, so there is nothing to hand over |
53
+
54
+ ## Upgrading
55
+
56
+ ```bash
57
+ npm install --save-dev @sddio/cli@latest
58
+ npx sddio init
59
+ ```
60
+
61
+ `.sddio/` is refreshed in place, and `sddio_workspace/` is left alone. `init` then prints the reconcile prompt, so paste it in and let the agent update only the artefacts the upgrade affects. An upgrade resets the reconciliation cursor to `null`, so this step isn't optional. Without it the workspace stays `unknown` and every session re-checks from scratch.
62
+
63
+ ## Commands
64
+
65
+ ```text
66
+ sddio init [--dir <path>] [--force] [--dry-run]
67
+ sddio skill --print
68
+ ```
69
+
70
+ | Command / flag | Effect |
71
+ | -------------- | ------ |
72
+ | `init` | Create `.sddio/`, `sddio_workspace/` and the seed collections; register `AGENTS.md`; print the next step |
73
+ | `skill --print` | Print the agent skill to stdout. Writes nothing |
74
+ | `--dir <path>` | Target project root (default: current directory) |
75
+ | `--force` | Overwrite existing files, including `sddio_workspace/` seeds |
76
+ | `--dry-run` | Report what would change without writing |
77
+
78
+ `.sddio/` belongs to the package and gets refreshed on init. `sddio_workspace/` is yours and is only touched with `--force`. A run that finds everything up to date reports all files as skipped.
79
+
80
+ `--force` resets the workspace seeds to empty files — it is meant for re-initialising a project, not for merging.
81
+
82
+ ## What lands in a project
83
+
84
+ ```text
85
+ .sddio/ # context layer, identical to the sddio repository's own .sddio/
86
+ context/… # instructions, schema, routes, principles, preferences, roadmap
87
+ sddio_workspace/ # the user's workspace: layout only, empty seeds
88
+ spec/spec_100.md # → 0 bytes
89
+ adr/adr_100.md # → 0 bytes
90
+ discussions/discussions_100.md
91
+ flow/active/template.md
92
+ flow/completed/ # empty directories, created explicitly
93
+ flow/reconciliation/
94
+ AGENTS.md # sddio snippet appended, existing content preserved
95
+ ```
96
+
97
+ The workspace ships no starter prose on purpose. It belongs to your project, and placeholder text would be rewritten immediately anyway. See ADR-005 in the sddio repository.
98
+
99
+ ## Agent skill
100
+
101
+ Agents that support skills can discover sddio without reading `AGENTS.md` first. `skill --print` writes the skill to stdout and nothing else; hints go to stderr, so it can be redirected straight into a skills directory:
102
+
103
+ ```bash
104
+ # your agent's skills directory — the CLI neither knows nor guesses it
105
+ SKILLS_DIR="$HOME/.config/your-agent/skills"
106
+
107
+ mkdir -p "$SKILLS_DIR/sddio"
108
+ npx sddio skill --print > "$SKILLS_DIR/sddio/SKILL.md"
109
+ ```
110
+
111
+ The skill is a router, not a copy of the rules. It names the paths, the invariants and the `grep` that lists entries, then hands the detail to `.sddio/context/instructions.md`, so an upgraded context layer doesn't invalidate it.
112
+
113
+ The CLI never scans or writes agent configuration directories, and never edits files outside the project. `init` also leaves the file at `.sddio/skill/SKILL.md`, so you can copy it without running anything.
114
+
115
+ ## Requirements
116
+
117
+ - Node ≥ 18. No Python, no global install.
118
+ - git optional: without a repository — or without the git binary — the commit check is skipped and the cursor is left untouched.
119
+
120
+ ## Questions
121
+
122
+ **Does it need a specific agent?** No. `init` writes `AGENTS.md` and nothing else agent-specific; any agent that reads repository files works, and the prompt it prints is plain text. `skill --print` exists for agents that support skills.
123
+
124
+ **Does it send anything anywhere?** No account, no server, no telemetry, no update check. It reads and writes files inside the target directory and runs no git command.
125
+
126
+ **What does it not do?** It does not write code, search or index the workspace, or enforce its rules — there is no `check` command, so a workspace that drifts cannot fail CI. Entries are Markdown; `grep` is the query language.
127
+
128
+ See [`docs/faq.md`](https://github.com/benxgao/sddio/blob/master/docs/faq.md) for the rest.
129
+
130
+ ## Development
131
+
132
+ ```bash
133
+ npm install
134
+ npm run build # regenerates templates/.sddio, then compiles
135
+ npm test
136
+ npm pack
137
+ ```
138
+
139
+ `templates/` is a build artefact, not source. `npm run sync` (run automatically by `build` and `pack`) recreates `templates/.sddio` from this repository's root `.sddio/`, which is the single source of truth. That way the shipped context can't drift from the one this repo dogfoods. The directory is git-ignored. The workspace layout lives in `lib/workspace.ts`.
140
+
141
+ The prompts printed by `init` live in `lib/prompt.ts`. The copies in this README and in the repository README are asserted against it by `test/prompt.test.mjs`, so they can't drift.
142
+
143
+ See `TESTING.md` for testing the packed tarball in another local project.
package/dist/agents.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * AGENTS.md registration (SPEC-004).
3
+ *
4
+ * The snippet is delimited so registration is detectable, idempotent and
5
+ * updatable: a changed snippet replaces the existing block instead of being
6
+ * appended a second time.
7
+ */
8
+ export const AGENTS_BEGIN = '<!-- sddio:begin -->';
9
+ export const AGENTS_END = '<!-- sddio:end -->';
10
+ export const AGENTS_SNIPPET = [
11
+ AGENTS_BEGIN,
12
+ 'This project uses sddio. Read `.sddio/context/instructions.md` before working.',
13
+ AGENTS_END,
14
+ ].join('\n');
15
+ export function ensureAgentsSnippet(existing) {
16
+ if (existing === null || existing.trim() === '') {
17
+ return { content: `${AGENTS_SNIPPET}\n`, changed: true };
18
+ }
19
+ const start = existing.indexOf(AGENTS_BEGIN);
20
+ if (start === -1) {
21
+ return { content: `${existing.trimEnd()}\n\n${AGENTS_SNIPPET}\n`, changed: true };
22
+ }
23
+ const end = existing.indexOf(AGENTS_END, start);
24
+ if (end === -1) {
25
+ return { content: `${existing.trimEnd()}\n\n${AGENTS_SNIPPET}\n`, changed: true };
26
+ }
27
+ const block = existing.slice(start, end + AGENTS_END.length);
28
+ if (block === AGENTS_SNIPPET) {
29
+ return { content: existing, changed: false };
30
+ }
31
+ const content = existing.slice(0, start) + AGENTS_SNIPPET + existing.slice(end + AGENTS_END.length);
32
+ return { content, changed: true };
33
+ }
package/dist/cli.js ADDED
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Entry point. Compiled to `dist/cli.js`, which is what `bin` points at, so
4
+ * `npx @sddio/cli` runs prebuilt output with no build step on the consumer
5
+ * side (ADR-002).
6
+ */
7
+ import { readFileSync } from 'node:fs';
8
+ import { join, resolve } from 'node:path';
9
+ import { runInit } from './init.js';
10
+ import { packageRoot } from './paths.js';
11
+ import { renderNextStep, selectNextStep } from './prompt.js';
12
+ import { readSkill, skillPath } from './skill.js';
13
+ const USAGE = `sddio — spec-driven development artifacts for a project
14
+
15
+ Usage:
16
+ sddio init [--dir <path>] [--force] [--dry-run]
17
+ sddio skill --print
18
+ sddio --version
19
+ sddio --help
20
+
21
+ Commands:
22
+ init Copy .sddio and sddio_workspace templates into the target project
23
+ and register the sddio snippet in AGENTS.md.
24
+ skill Print the sddio agent skill to stdout. Reads only: no file is
25
+ written, and no agent directory is touched.
26
+
27
+ Options:
28
+ --dir <path> Target project root (default: current directory)
29
+ --force Overwrite existing files, including sddio_workspace
30
+ --dry-run Report what would happen without writing anything
31
+ --print Print the skill (skill only)
32
+ -h, --help Show this help
33
+ -v, --version Show the version
34
+ `;
35
+ function readVersion() {
36
+ const manifest = readFileSync(join(packageRoot, 'package.json'), 'utf8');
37
+ return JSON.parse(manifest).version;
38
+ }
39
+ function parseInitArgs(args) {
40
+ const parsed = { cwd: process.cwd(), force: false, dryRun: false };
41
+ for (let index = 0; index < args.length; index += 1) {
42
+ const argument = args[index];
43
+ if (argument === '--force') {
44
+ parsed.force = true;
45
+ }
46
+ else if (argument === '--dry-run') {
47
+ parsed.dryRun = true;
48
+ }
49
+ else if (argument === '--dir') {
50
+ const value = args[index + 1];
51
+ if (value === undefined) {
52
+ throw new Error('--dir requires a path');
53
+ }
54
+ parsed.cwd = resolve(value);
55
+ index += 1;
56
+ }
57
+ else {
58
+ throw new Error(`Unknown option: ${String(argument)}`);
59
+ }
60
+ }
61
+ return parsed;
62
+ }
63
+ function report(result) {
64
+ const label = (value) => value.padEnd(12);
65
+ console.log(`sddio init ${readVersion()}${result.dryRun ? ' (dry run)' : ''}`);
66
+ console.log(`target: ${result.target}\n`);
67
+ for (const file of result.overwritten) {
68
+ console.log(` ${label('overwritten')}${file}`);
69
+ }
70
+ for (const file of result.created) {
71
+ console.log(` ${label('created')}${file}`);
72
+ }
73
+ for (const file of result.skipped) {
74
+ console.log(` ${label('skipped')}${file}`);
75
+ }
76
+ console.log(`\ncreated ${result.created.length}, overwritten ${result.overwritten.length}, skipped ${result.skipped.length}`);
77
+ if (result.dryRun) {
78
+ console.log('dry run: nothing was written');
79
+ }
80
+ for (const error of result.errors) {
81
+ console.error(`error: ${error}`);
82
+ }
83
+ }
84
+ async function commandInit(args) {
85
+ const result = await runInit(parseInitArgs(args));
86
+ report(result);
87
+ if (result.errors.length > 0) {
88
+ return 1;
89
+ }
90
+ if (result.dryRun) {
91
+ console.log('dry run: run again without --dry-run to initialise, then paste the prompt it prints');
92
+ return 0;
93
+ }
94
+ console.log(`\n${renderNextStep(selectNextStep(result.created.length, result.overwritten.length))}`);
95
+ return 0;
96
+ }
97
+ async function commandSkill(args) {
98
+ for (const argument of args) {
99
+ if (argument !== '--print') {
100
+ throw new Error(`Unknown option for skill: ${argument}`);
101
+ }
102
+ }
103
+ process.stdout.write(await readSkill());
104
+ console.error(`No file was written. Source: ${skillPath}`);
105
+ console.error('Save it as <skills>/sddio/SKILL.md, or copy .sddio/skill/SKILL.md from the project.');
106
+ return 0;
107
+ }
108
+ async function main(args) {
109
+ if (args.includes('-h') || args.includes('--help')) {
110
+ console.log(USAGE);
111
+ return 0;
112
+ }
113
+ if (args.includes('-v') || args.includes('--version')) {
114
+ console.log(readVersion());
115
+ return 0;
116
+ }
117
+ const [command, ...rest] = args;
118
+ if (command === undefined) {
119
+ console.log(USAGE);
120
+ return 1;
121
+ }
122
+ try {
123
+ switch (command) {
124
+ case 'init':
125
+ return await commandInit(rest);
126
+ case 'skill':
127
+ return await commandSkill(rest);
128
+ default:
129
+ console.error(`Unknown command: ${command}\n`);
130
+ console.log(USAGE);
131
+ return 1;
132
+ }
133
+ }
134
+ catch (error) {
135
+ console.error(`error: ${error.message}`);
136
+ return 1;
137
+ }
138
+ }
139
+ const exitCode = await main(process.argv.slice(2));
140
+ process.exitCode = exitCode;
package/dist/init.js ADDED
@@ -0,0 +1,117 @@
1
+ /**
2
+ * `sddio init` — lay down `.sddio/` and `sddio_workspace/` in a project.
3
+ *
4
+ * Ownership rules (ADR-001, SPEC-003):
5
+ * - `.sddio/` is package-owned: refreshed on every run, so upgrades carry the
6
+ * current context layer.
7
+ * - `sddio_workspace/` is user-owned: created once, never overwritten unless
8
+ * `--force`.
9
+ *
10
+ * The two roots are produced differently on purpose (ADR-005). `.sddio/` is
11
+ * copied from the tarball. `sddio_workspace/` is only a layout — directories
12
+ * plus empty seed files — so it is built from `lib/workspace.ts` rather than
13
+ * from template files, and empty directories survive because they are created
14
+ * explicitly rather than carried by the package.
15
+ */
16
+ import { copyFile, mkdir, readdir, readFile, writeFile } from 'node:fs/promises';
17
+ import { existsSync } from 'node:fs';
18
+ import { dirname, join, resolve } from 'node:path';
19
+ import { ensureAgentsSnippet } from './agents.js';
20
+ import { contextTemplateRoot } from './paths.js';
21
+ import { WORKSPACE_DIRS, WORKSPACE_SEEDS } from './workspace.js';
22
+ function toSegments(relativePath) {
23
+ return relativePath.split('/');
24
+ }
25
+ async function listFiles(root, prefix = '') {
26
+ const entries = await readdir(join(root, ...toSegments(prefix)), { withFileTypes: true });
27
+ const files = [];
28
+ for (const entry of entries) {
29
+ const relativePath = prefix === '' ? entry.name : `${prefix}/${entry.name}`;
30
+ if (entry.isDirectory()) {
31
+ files.push(...(await listFiles(root, relativePath)));
32
+ }
33
+ else if (entry.isFile()) {
34
+ files.push(relativePath);
35
+ }
36
+ }
37
+ return files.sort();
38
+ }
39
+ /** `.sddio/` — package-owned, copied as `templates/.sddio/<path>` → `.sddio/<path>`. */
40
+ async function copyContext(target, dryRun, result) {
41
+ for (const relativePath of await listFiles(contextTemplateRoot)) {
42
+ const source = join(contextTemplateRoot, ...toSegments(relativePath));
43
+ const destination = join(target, '.sddio', ...toSegments(relativePath));
44
+ const exists = existsSync(destination);
45
+ try {
46
+ if (exists && (await readFile(destination)).equals(await readFile(source))) {
47
+ result.skipped.push(`.sddio/${relativePath}`);
48
+ continue;
49
+ }
50
+ if (!dryRun) {
51
+ await mkdir(dirname(destination), { recursive: true });
52
+ await copyFile(source, destination);
53
+ }
54
+ (exists ? result.overwritten : result.created).push(`.sddio/${relativePath}`);
55
+ }
56
+ catch (error) {
57
+ result.errors.push(`.sddio/${relativePath}: ${error.message}`);
58
+ }
59
+ }
60
+ }
61
+ /** `sddio_workspace/` — user-owned: directories plus empty seeds. */
62
+ async function seedWorkspace(target, options, result) {
63
+ const dryRun = options.dryRun === true;
64
+ for (const directory of WORKSPACE_DIRS) {
65
+ if (!dryRun) {
66
+ await mkdir(join(target, ...toSegments(directory)), { recursive: true });
67
+ }
68
+ }
69
+ for (const relativePath of WORKSPACE_SEEDS) {
70
+ const destination = join(target, ...toSegments(relativePath));
71
+ const exists = existsSync(destination);
72
+ if (exists && options.force !== true) {
73
+ result.skipped.push(relativePath);
74
+ continue;
75
+ }
76
+ try {
77
+ if (!dryRun) {
78
+ await mkdir(dirname(destination), { recursive: true });
79
+ await writeFile(destination, '', 'utf8');
80
+ }
81
+ (exists ? result.overwritten : result.created).push(relativePath);
82
+ }
83
+ catch (error) {
84
+ result.errors.push(`${relativePath}: ${error.message}`);
85
+ }
86
+ }
87
+ }
88
+ async function registerAgents(target, dryRun, result) {
89
+ const agentsPath = join(target, 'AGENTS.md');
90
+ const existing = existsSync(agentsPath) ? await readFile(agentsPath, 'utf8') : null;
91
+ const snippet = ensureAgentsSnippet(existing);
92
+ if (!snippet.changed) {
93
+ result.skipped.push('AGENTS.md');
94
+ return;
95
+ }
96
+ try {
97
+ if (!dryRun) {
98
+ await writeFile(agentsPath, snippet.content, 'utf8');
99
+ }
100
+ (existing === null ? result.created : result.overwritten).push('AGENTS.md');
101
+ }
102
+ catch (error) {
103
+ result.errors.push(`AGENTS.md: ${error.message}`);
104
+ }
105
+ }
106
+ export async function runInit(options) {
107
+ const target = resolve(options.cwd);
108
+ const dryRun = options.dryRun === true;
109
+ const result = { target, dryRun, created: [], skipped: [], overwritten: [], errors: [] };
110
+ if (!existsSync(contextTemplateRoot)) {
111
+ throw new Error(`Templates are missing from the package: ${contextTemplateRoot}`);
112
+ }
113
+ await copyContext(target, dryRun, result);
114
+ await seedWorkspace(target, options, result);
115
+ await registerAgents(target, dryRun, result);
116
+ return result;
117
+ }
package/dist/paths.js ADDED
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Resolve the package root and template location.
3
+ *
4
+ * Templates ship inside the published tarball, so they are always resolved
5
+ * relative to the package artefact — never to the consumer's repository
6
+ * (ADR-003). The executing file lives in `dist/`, which carries no
7
+ * `package.json`, so the root is found by walking up.
8
+ */
9
+ import { existsSync } from 'node:fs';
10
+ import { dirname, join } from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ const here = dirname(fileURLToPath(import.meta.url));
13
+ function findPackageRoot(start) {
14
+ let current = start;
15
+ for (;;) {
16
+ if (existsSync(join(current, 'package.json'))) {
17
+ return current;
18
+ }
19
+ const parent = dirname(current);
20
+ if (parent === current) {
21
+ return start;
22
+ }
23
+ current = parent;
24
+ }
25
+ }
26
+ export const packageRoot = findPackageRoot(here);
27
+ /**
28
+ * `templates/.sddio` — the context layer, generated at build time from the
29
+ * repository root `.sddio/` (ADR-005).
30
+ */
31
+ export const contextTemplateRoot = join(packageRoot, 'templates', '.sddio');
package/dist/prompt.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * What `init` leaves the user with.
3
+ *
4
+ * The file list is not the useful output — the next action is. `init` cannot
5
+ * perform it (the agent has to read and classify), so it hands over a prompt
6
+ * meant to be pasted verbatim into whatever coding agent is in use.
7
+ *
8
+ * Three outcomes, because the right next step differs:
9
+ * - `bootstrap` — this run created files, so the workspace is new.
10
+ * - `reconcile` — only `.sddio/` changed, i.e. an upgrade; knowledge may be stale.
11
+ * - `current` — nothing changed, so there is nothing to ask the agent to do.
12
+ */
13
+ const RULE = '─'.repeat(64);
14
+ export const BOOTSTRAP_PROMPT = [
15
+ 'Read `.sddio/context/instructions.md` and follow it.',
16
+ '',
17
+ 'This project has just been initialised with sddio. Before any other work:',
18
+ '',
19
+ '1. Run the commit check in `.sddio/context/instructions/reconciliation.md`.',
20
+ ' `config.json` has no baseline yet, so the state is `unknown`.',
21
+ '2. Bootstrap the workspace as described in `instructions/bootstrap.md`:',
22
+ ' derive the minimum SPEC from the existing code, configuration, tests and',
23
+ ' documentation. Do not ask me for facts the repository already contains.',
24
+ '3. Record at least one DISCUSSION for what the repository cannot settle, so',
25
+ ' the workspace opens with an open question and not only with claims.',
26
+ '4. Report what you recorded, then set `lastProcessedCommit` to `HEAD` and',
27
+ ' `previousCommit` to `HEAD^` in `.sddio/context/config.json`',
28
+ ' (`null` at a root commit).',
29
+ '',
30
+ 'Then answer this: <your first task>',
31
+ ].join('\n');
32
+ export const RECONCILE_PROMPT = [
33
+ 'Read `.sddio/context/instructions.md` and follow it.',
34
+ '',
35
+ 'The sddio context layer in `.sddio/` was just refreshed by a package upgrade,',
36
+ 'and `config.json` now carries no baseline (`null`). Before any other work, run',
37
+ 'the commit check and reconcile: `.sddio/context/instructions/reconciliation.md`.',
38
+ '',
39
+ 'The cursor state is `unknown`, so there is no range to diff: verify the existing',
40
+ 'artifacts against the current implementation. Do not rescan unrelated areas, and',
41
+ 'do not rewrite artifacts that are still accurate.',
42
+ '',
43
+ 'Report what you understood and what you changed, then set `lastProcessedCommit`',
44
+ 'to `HEAD` and `previousCommit` to `HEAD^` in `.sddio/context/config.json`',
45
+ '(`null` at a root commit), so the next session resumes from a baseline.',
46
+ '',
47
+ 'Then answer this: <your first task>',
48
+ ].join('\n');
49
+ export function selectNextStep(created, overwritten) {
50
+ if (created > 0) {
51
+ return 'bootstrap';
52
+ }
53
+ return overwritten > 0 ? 'reconcile' : 'current';
54
+ }
55
+ export function renderNextStep(step) {
56
+ if (step === 'current') {
57
+ return 'Already up to date. Nothing to hand to your agent until the next change.';
58
+ }
59
+ const prompt = step === 'bootstrap' ? BOOTSTRAP_PROMPT : RECONCILE_PROMPT;
60
+ return [RULE, 'Paste this into your coding agent', RULE, '', prompt].join('\n');
61
+ }
package/dist/skill.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The sddio agent skill (ADR-008).
3
+ *
4
+ * The skill ships inside the package as `.sddio/skill/SKILL.md`, generated at
5
+ * build time with the rest of the context layer. The CLI only reads it: nothing
6
+ * is written into an agent's skills directory, because that would mean editing
7
+ * files outside the repository with no reliable way to undo it.
8
+ *
9
+ * It is a router. It names paths and invariants, never the rules themselves, so
10
+ * it keeps working when `.sddio/` is upgraded underneath it.
11
+ */
12
+ import { readFile } from 'node:fs/promises';
13
+ import { join } from 'node:path';
14
+ import { contextTemplateRoot } from './paths.js';
15
+ export const skillPath = join(contextTemplateRoot, 'skill', 'SKILL.md');
16
+ export async function readSkill() {
17
+ return readFile(skillPath, 'utf8');
18
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `sddio_workspace/` layout (SPEC-002, ADR-005).
3
+ *
4
+ * The workspace is user-owned, so init reproduces the layout and nothing else:
5
+ * the directories plus empty seed files. Seeds ship empty on purpose — they
6
+ * are the user's project, not ours, and placeholder prose is immediately
7
+ * rewritten anyway.
8
+ *
9
+ * Empty directories cannot travel through `npm pack`, so the layout is
10
+ * declared here instead of being carried by the tarball.
11
+ */
12
+ export const WORKSPACE_ROOT = 'sddio_workspace';
13
+ /** Created unconditionally, including the empty ones a template cannot carry. */
14
+ export const WORKSPACE_DIRS = [
15
+ WORKSPACE_ROOT,
16
+ `${WORKSPACE_ROOT}/spec`,
17
+ `${WORKSPACE_ROOT}/adr`,
18
+ `${WORKSPACE_ROOT}/discussions`,
19
+ `${WORKSPACE_ROOT}/flow`,
20
+ `${WORKSPACE_ROOT}/flow/active`,
21
+ `${WORKSPACE_ROOT}/flow/completed`,
22
+ `${WORKSPACE_ROOT}/flow/reconciliation`,
23
+ ];
24
+ /** Entry home files (ADR-004: FLOW files are slug-named, not numbered). */
25
+ export const WORKSPACE_SEEDS = [
26
+ `${WORKSPACE_ROOT}/spec/spec_100.md`,
27
+ `${WORKSPACE_ROOT}/adr/adr_100.md`,
28
+ `${WORKSPACE_ROOT}/discussions/discussions_100.md`,
29
+ `${WORKSPACE_ROOT}/flow/active/template.md`,
30
+ ];
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@sddio/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Spec-driven development for coding agents: keep SPEC, ADR, DISCUSSION and FLOW in your repo so the reasoning survives session restarts.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "sddio": "dist/cli.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "templates"
13
+ ],
14
+ "engines": {
15
+ "node": ">=18.0.0"
16
+ },
17
+ "publishConfig": {
18
+ "access": "public"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/benxgao/sddio.git",
23
+ "directory": "packages/cli"
24
+ },
25
+ "homepage": "https://github.com/benxgao/sddio/tree/master/packages/cli",
26
+ "bugs": {
27
+ "url": "https://github.com/benxgao/sddio/issues"
28
+ },
29
+ "keywords": [
30
+ "sddio",
31
+ "spec-driven-development",
32
+ "spec-driven",
33
+ "coding-agents",
34
+ "ai-agents",
35
+ "context-engineering",
36
+ "claude-code",
37
+ "cursor",
38
+ "agents-md",
39
+ "adr",
40
+ "cli",
41
+ "scaffold"
42
+ ],
43
+ "scripts": {
44
+ "sync": "node scripts/sync-templates.mjs",
45
+ "prebuild": "npm run sync",
46
+ "build": "tsc -p tsconfig.json",
47
+ "pretest": "npm run build",
48
+ "test": "node --test test/*.test.mjs",
49
+ "prepack": "npm run build",
50
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true});require('node:fs').rmSync('templates',{recursive:true,force:true})\""
51
+ },
52
+ "devDependencies": {
53
+ "@types/node": "^20.14.0",
54
+ "typescript": "^5.5.0"
55
+ }
56
+ }