silvermoon 0.0.1

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/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "silvermoon",
3
+ "version": "0.0.1",
4
+ "description": "The project spirit that checks repository state and answers what's next.",
5
+ "packageManager": "pnpm@11.22.0",
6
+ "type": "module",
7
+ "bin": {
8
+ "silvermoon": "bin/silvermoon.js"
9
+ },
10
+ "exports": {
11
+ ".": "./src/index.js"
12
+ },
13
+ "files": [
14
+ "assets/silvermoon.svg",
15
+ "bin",
16
+ "skills/silvermoon",
17
+ "src",
18
+ "README.md",
19
+ "README.zh-CN.md",
20
+ "schema"
21
+ ],
22
+ "scripts": {
23
+ "check": "npm run check:quick && npm run test:integration && npm run pack:check && npm run test:e2e && npm run check:skills",
24
+ "check:quick": "node --check bin/silvermoon.js && npm test",
25
+ "check:skills": "npx skills add . --list",
26
+ "pack:check": "node scripts/check-pack.js",
27
+ "prepare:npm-release": "node scripts/prepare-npm-release.mjs",
28
+ "test": "npm run test:unit && npm run test:contract",
29
+ "test:contract": "node --test \"test/contract/*.test.*\"",
30
+ "test:e2e": "node --test \"test/e2e/*.test.*\"",
31
+ "test:integration": "node --test \"test/integration/*.test.*\"",
32
+ "test:unit": "node --test \"test/unit/*.test.*\""
33
+ },
34
+ "engines": {
35
+ "node": ">=22"
36
+ },
37
+ "keywords": [
38
+ "agent-skills",
39
+ "cli",
40
+ "project-state",
41
+ "repository",
42
+ "validation",
43
+ "whats-next"
44
+ ],
45
+ "license": "UNLICENSED",
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "registry": "https://registry.npmjs.org/"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/shazhou-ww/silvermoon.git"
53
+ },
54
+ "devDependencies": {
55
+ "ajv": "^8.20.0",
56
+ "semver": "^7.8.5"
57
+ },
58
+ "dependencies": {
59
+ "commander": "^14.0.3",
60
+ "marked": "^18.0.13",
61
+ "mdast-util-from-markdown": "^2.0.3",
62
+ "mdast-util-to-markdown": "^2.1.2",
63
+ "yaml": "^2.9.1"
64
+ }
65
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/shazhou-ww/silvermoon/raw/refs/heads/main/schema/v1/config.schema.json",
4
+ "title": "Silvermoon repository configuration v1",
5
+ "description": "The repository-owned .silvermoon/config.yaml contract.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "version",
10
+ "primaryRepository",
11
+ "primaryBranch"
12
+ ],
13
+ "properties": {
14
+ "version": {
15
+ "const": 1
16
+ },
17
+ "primaryRepository": {
18
+ "$ref": "definitions.schema.json#/$defs/repository"
19
+ },
20
+ "primaryBranch": {
21
+ "$ref": "definitions.schema.json#/$defs/branch"
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,25 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/shazhou-ww/silvermoon/raw/refs/heads/main/schema/v1/definitions.schema.json",
4
+ "title": "Silvermoon shared definitions v1",
5
+ "description": "Shared value definitions for Silvermoon version 1 storage contracts.",
6
+ "$defs": {
7
+ "branch": {
8
+ "type": "string",
9
+ "pattern": "^(?!-)(?!/)(?!@$)(?!refs/)(?!remotes/)(?!.*\\.\\.)(?!.*@\\{)(?!.*[ ~^:?*\\[\\\\])(?!.*(?:^|/)\\.)(?!.*(?:^|/)[^/]*\\.lock(?:/|$))(?!.*//$)(?!.*//)(?!.*\\.$)(?!.*\/$).+$"
10
+ },
11
+ "repository": {
12
+ "type": "string",
13
+ "format": "uri",
14
+ "pattern": "^https://(?:[a-z0-9](?:[a-z0-9.-]*[a-z0-9])?|\\[[0-9a-f:.]+\\])(?::(?!443(?:/|$))[0-9]+)?/(?!/)(?!.*//)(?!.*\\\\)(?!.*(?:/\\.{1,2})(?:/|$))(?!.*%(?:2[eEfF]|5[cC]))(?!.*[?#])[^/](?:.*[^/])?$"
15
+ },
16
+ "ulid": {
17
+ "type": "string",
18
+ "pattern": "^[0-7][0-9A-HJKMNP-TV-Z]{25}$"
19
+ },
20
+ "objectId": {
21
+ "type": "string",
22
+ "pattern": "^(?:[0-9a-f]{40}|[0-9a-f]{64})$"
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://github.com/shazhou-ww/silvermoon/raw/refs/heads/main/schema/v1/idea-status.schema.json",
4
+ "title": "Silvermoon idea status v1",
5
+ "description": "The repository-owned .silvermoon/ideas/<IDEA_ID>/status.yaml contract.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": [
9
+ "version",
10
+ "id"
11
+ ],
12
+ "properties": {
13
+ "version": {
14
+ "const": 1
15
+ },
16
+ "id": {
17
+ "$ref": "definitions.schema.json#/$defs/ulid"
18
+ },
19
+ "alias": {
20
+ "type": "string",
21
+ "minLength": 1,
22
+ "maxLength": 120,
23
+ "pattern": "^(?!\\s)(?!.*\\s$)[^\\u0000-\\u001f\\u007f-\\u009f]+$"
24
+ },
25
+ "abandoned": {
26
+ "const": true
27
+ },
28
+ "approvedRevision": {
29
+ "description": "Accepted Ideal World (道心) tree object ID.",
30
+ "$ref": "definitions.schema.json#/$defs/objectId"
31
+ },
32
+ "implementationAcceptedRevision": {
33
+ "description": "Accepted Inner World (内景) tree object ID.",
34
+ "$ref": "definitions.schema.json#/$defs/objectId"
35
+ },
36
+ "deploymentAcceptedRevision": {
37
+ "description": "Accepted Outer World (现世) tree object ID.",
38
+ "$ref": "definitions.schema.json#/$defs/objectId"
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,209 @@
1
+ ---
2
+ name: silvermoon
3
+ description: "Navigate or create repository-owned ideas, execute one safe action, and reobserve only after an observable delta."
4
+ argument-hint: "[new | idea ULID or alias]"
5
+ user-invocable: true
6
+ ---
7
+
8
+ # Silvermoon
9
+
10
+ Use Silvermoon to navigate or explicitly create ideas against the configured
11
+ remote primary. The CLI derives idea state and checks repository hygiene; the
12
+ Agent performs suggested repository or external actions through ordinary tools
13
+ and Git.
14
+
15
+ ## Start From Primary
16
+
17
+ 1. Preserve the user's intent when choosing the entry command:
18
+ - For `/silvermoon new` or any other explicit request to create a new idea,
19
+ run `silvermoon create-idea --json`.
20
+ - Otherwise run `silvermoon whats-next [idea] --json`. Pass the selector only
21
+ when the user supplied or previously selected one.
22
+ 2. Treat the command, request, `observedPrimaryCommit`, `selectedIdea`, and
23
+ action or created idea as one immutable observation. Do not combine guidance
24
+ from different reports.
25
+ 3. Read the complete `onboarding` doctor report. It lists every requirement,
26
+ status, blocking flag, dependency, structured remediation, recommended
27
+ action, and recheck command. For `adopt-silvermoon`, execute only the
28
+ recommended explicit remediation (or safely resolve its conflict), then
29
+ recheck; do not route idea work while blocking findings remain.
30
+ 4. Execute only the highest-priority action. Do not skip worktree, conflict,
31
+ sync, or selection guidance to reach a later idea-state action. An explicit
32
+ create request is not idea selection: after resolving a blocking hygiene
33
+ action, retry `create-idea`, not selector-less `whats-next`.
34
+
35
+ `whats-next` may fetch and inspect. It never checkout, merges, edits, commits,
36
+ stashes, deletes, resets, fast-forwards, or pushes. `create-idea` runs the same
37
+ hygiene preflight and, only when it passes, creates the structured idea scaffold.
38
+ Dependency installation and skill registration are separate explicit
39
+ operations. The packaged skill is canonical, while registration and updates
40
+ belong to the supported `npx skills add` interface. Silvermoon reports
41
+ configuration and skill findings but owns no onboarding mutation command.
42
+
43
+ ## Preserve Work
44
+
45
+ - Read exact staged, unstaged, and untracked diffs before deciding ownership.
46
+ - Preserve unknown, unrelated, or user-authored changes. Isolate them in
47
+ another worktree or use an explicitly described stash only when needed.
48
+ - Delete only paths created by the current operation or paths the user names
49
+ after reviewing the current diff.
50
+ - Never use force-push, `reset --hard`, broad clean commands, or silent history
51
+ rewrites to satisfy guidance.
52
+ - Publish with the observed primary tip as the expected remote tip. On rejection
53
+ or concurrent movement, fetch and call `whats-next` again; never replay a stale
54
+ approval or acceptance automatically.
55
+
56
+ ## Execute Actions
57
+
58
+ - `select-active-idea`: show the ordered candidates and obtain one explicit
59
+ ULID or alias selection.
60
+ - `continue-active-idea`: call `whats-next <id>` to obtain state guidance.
61
+ - `create-idea`: this action is internal to the explicit `create-idea` command's
62
+ preflight; do not replace the user's create intent with active-idea
63
+ selection. After hygiene passes, the command creates one self-contained idea
64
+ with structured `Idea.md`, `Implementation.md`, `Deployment.md`, and
65
+ `ledger.md` entries plus alias-less `status.yaml`. It never stages, commits,
66
+ pushes, or records a decision. Review every generated path before
67
+ publication. During initial preparation, replace the `Idea.md` guidance with
68
+ the requested Ideal World contract, but keep the Implementation, Deployment,
69
+ and matching ledger placeholders synchronized until their lifecycle actions.
70
+ An Agent may add a concise, unique alias derived from the user's request;
71
+ do not interrupt the user only to ask them to name it.
72
+ - `switch-to-primary`, `resolve-conflicts`, `inspect-worktree-changes`,
73
+ `fast-forward-primary`, `integrate-primary`, `publish-primary`: perform the
74
+ exact Git hygiene step without discarding either history or unknown work.
75
+ - `prepare-idea`: edit `Idea.md` and supporting files in the Ideal World
76
+ (道心). Supporting files must serve `Idea.md`, never replace it as a second
77
+ contract. After lifecycle hygiene, use the reported `ledgerPath` to resume
78
+ relevant unfinished work. After explicit approval, write the reported
79
+ `idealRevision` to `approvedRevision`.
80
+ - `implement-idea`: edit `Implementation.md`, its supporting Inner World
81
+ (内景) files, and repository deliverables. Do not change the nested Ideal
82
+ World unless the ideal truly changed and should return to preparing. After
83
+ lifecycle hygiene, use the reported `ledgerPath` to resume relevant
84
+ unfinished work. After explicit acceptance, write the reported
85
+ `implementationRevision` to `implementationAcceptedRevision`.
86
+ - `deploy-idea`: use `Deployment.md` and its supporting Outer World (现世)
87
+ files to drive and verify the external world. Do not change repository
88
+ deliverables as deployment work or modify a nested world unless that earlier
89
+ contract truly changed. Publish a newly authored or materially changed
90
+ deployment contract first, reobserve its stable `deploymentRevision`, then
91
+ execute external checks against that revision and record their completion in
92
+ the ledger. After lifecycle hygiene, use the reported `ledgerPath` to resume
93
+ relevant unfinished work. After explicit acceptance, write the reported
94
+ `deploymentRevision` to `deploymentAcceptedRevision`.
95
+ - `review-abandoned`: keep `abandoned: true`, remove it after an explicit human
96
+ decision, or create a different idea.
97
+ - `review-completed`: revise the existing idea definition or create a new idea.
98
+
99
+ ## Author The Three Worlds
100
+
101
+ Every idea uses this fixed structure:
102
+
103
+ ```text
104
+ .silvermoon/ideas/<ULID>/
105
+ ├── status.yaml
106
+ ├── ledger.md
107
+ └── outer/
108
+ ├── Deployment.md
109
+ └── inner/
110
+ ├── Implementation.md
111
+ └── ideal/
112
+ └── Idea.md
113
+ ```
114
+
115
+ `Idea.md` is the canonical Ideal World (道心) entry, `Implementation.md` is the
116
+ canonical Inner World (内景) entry, and `Deployment.md` is the canonical Outer
117
+ World (现世) entry: 道心立意,内景成形,现世验真. Each world may contain
118
+ additional files and nested directories, but those artifacts support their
119
+ same-world entry and do not define a second contract.
120
+
121
+ In `Implementation.md` and `Deployment.md`, put plans under `## Steps` and
122
+ outcome contracts under `## Acceptance criteria`. Give every step and criterion
123
+ a stable level-three heading: `I-Sxx`, `I-ACxx`, `D-Sxx`, or `D-ACxx`. A
124
+ criterion must describe both its observable outcome and the method that proves
125
+ it; do not add a separate validation section. Keep checkboxes out of world
126
+ contracts. World content changes its world revision and every containing world
127
+ revision; `status.yaml` and `ledger.md` stay outside all three world trees.
128
+
129
+ ## Continue From The Ledger
130
+
131
+ Every idea has an Agent-owned `ledger.md` at the path reported by `whats-next`.
132
+ It is operational state, not a fourth world, normative contract, or human
133
+ decision. Silvermoon requires the regular file but does not parse its body or
134
+ derive lifecycle state from it.
135
+
136
+ Mirror stable IDs and short titles from both world contracts:
137
+
138
+ ```markdown
139
+ # Ledger
140
+
141
+ ## Implementation
142
+
143
+ ### Steps
144
+
145
+ - [x] **I-S01:** Completed step
146
+ - [ ] **I-S02:** Remaining step
147
+
148
+ ### Acceptance criteria
149
+
150
+ - [x] **I-AC01:** Proven criterion
151
+ - [ ] **I-AC02:** Unproven criterion
152
+
153
+ ## Deployment
154
+
155
+ ### Steps
156
+
157
+ - [ ] **D-S01:** Deployment step
158
+
159
+ ### Acceptance criteria
160
+
161
+ - [ ] **D-AC01:** Deployment criterion
162
+ ```
163
+
164
+ When adding or removing a world step or criterion, update the matching ledger
165
+ entry in the same change. Keep its stable ID when only the title or details are
166
+ refined. Add new entries unchecked. If a completed item's requirement or proof
167
+ method changes materially, reset its checkbox and re-run the work or proof.
168
+ Infer the next action from `whats-next`, the world contracts, and unchecked
169
+ ledger entries; do not maintain duplicate Current or Next summaries.
170
+ If relevant ledger entries remain unchecked, continue the reported world
171
+ action. If all relevant entries are checked, their evidence remains valid, and
172
+ the candidate is published, stop editing and request explicit acceptance for
173
+ the exact revision reported by `whats-next`.
174
+
175
+ `[x]` means only that the Agent recorded work or a check as complete. It never
176
+ approves an Ideal World, accepts implementation or deployment, changes
177
+ `status.yaml`, or authorizes publication. Record test names, commands,
178
+ artifacts, and results in the corresponding world criterion or concise ledger
179
+ notes without creating a separate evidence schema or public API contract.
180
+
181
+ ## Write Status Facts
182
+
183
+ Silvermoon has no approval, acceptance, or abandonment mutation commands.
184
+ Update the idea's `status.yaml` with ordinary file editing:
185
+
186
+ 1. Reconfirm the decision applies to the selected idea and current
187
+ world revision reported by `whats-next`.
188
+ 2. Add or update only the corresponding revision field, or add/remove canonical
189
+ `abandoned: true` after an explicit human decision.
190
+ 3. Run `silvermoon check --worktree --json` while reviewing the complete
191
+ candidate, then stage it and run `silvermoon check --staged --json`.
192
+ 4. Commit the status decision separately when practical, then non-force push
193
+ with the observation's `observedPrimaryCommit` as expected tip.
194
+
195
+ Never infer a human decision from silence, prose, Git activity, or an outer
196
+ command. Old revision values remain as history and become inactive naturally
197
+ when the idea folder changes.
198
+
199
+ ## Advance The Loop
200
+
201
+ Re-run the intent-preserving entry command only after an expected repository
202
+ delta, an unexpected input change, or a newly arrived external result: use
203
+ `create-idea` for a pending explicit creation and `whats-next` otherwise. End
204
+ the current turn when waiting for human/external input. Report an actionable
205
+ error with its recovery condition, or report no progress and stop if guidance
206
+ completed without a delta. Never poll the same observation.
207
+
208
+ Follow [adoption.md](./references/adoption.md) when creating or explicitly
209
+ converting a repository to Silvermoon.
@@ -0,0 +1,122 @@
1
+ # Silvermoon adoption
2
+
3
+ ## New repositories
4
+
5
+ Start with a complete, read-only diagnosis, even in an unfamiliar repository:
6
+
7
+ ```sh
8
+ npx silvermoon@<version> whats-next --json
9
+ ```
10
+
11
+ The report distinguishes source checkout, project-local, temporary, global,
12
+ and unknown execution; lists all requirements and findings with dependencies;
13
+ and provides structured remediation plus a recheck command. Temporary
14
+ execution is only a bootstrap authority. Adopt its exact version, install it
15
+ project-locally, and thereafter use `npx --no-install silvermoon`.
16
+
17
+ Install and synchronize explicitly:
18
+
19
+ ```sh
20
+ npm install --save-dev --save-exact silvermoon@<version>
21
+ npx skills add ./node_modules/silvermoon/skills --skill silvermoon --agent github-copilot --yes --copy
22
+ ```
23
+
24
+ The npm package ships the canonical skill. Installation never writes tracked
25
+ skill files. Registration and updates belong to `npx skills`; Silvermoon
26
+ diagnoses the resulting repository-local content but never overwrites it.
27
+
28
+ Create `.silvermoon/config.yaml` with the fixed version 1 contract:
29
+
30
+ ```yaml
31
+ version: 1
32
+ primaryRepository: https://example.com/owner/repository.git
33
+ primaryBranch: main
34
+ ```
35
+
36
+ The URL is credential-free canonical HTTPS shared state; local Git credentials
37
+ and URL rewrites remain machine-local. Metadata and idea paths are fixed.
38
+
39
+ Commit the configuration, then run:
40
+
41
+ ```sh
42
+ silvermoon check --commit HEAD
43
+ silvermoon check --remote
44
+ silvermoon create-idea --json
45
+ silvermoon whats-next <ULID> --json
46
+ ```
47
+
48
+ Create or repair configuration through ordinary reviewed file editing.
49
+ Silvermoon reports every configuration finding but has no init or setup command.
50
+
51
+ ## Idea storage
52
+
53
+ Each idea is self-contained:
54
+
55
+ ```text
56
+ .silvermoon/ideas/<ULID>/
57
+ |-- status.yaml
58
+ |-- ledger.md
59
+ `-- outer/
60
+ |-- Deployment.md
61
+ `-- inner/
62
+ |-- Implementation.md
63
+ `-- ideal/
64
+ `-- Idea.md
65
+ ```
66
+
67
+ Ideal World (道心) uses `Idea.md`, Inner World (内景) uses
68
+ `Implementation.md`, and Outer World (现世) uses `Deployment.md`: 道心立意,
69
+ 内景成形,现世验真. Each world may have supporting files and directories,
70
+ but they serve rather than replace the canonical same-world entry.
71
+
72
+ The nested opaque Git trees produce `idealRevision`,
73
+ `implementationRevision`, and `deploymentRevision`. Inner World includes Ideal
74
+ World; Outer World includes both nested worlds. `status.yaml` and required
75
+ `ledger.md` are outside all three revisions. Silvermoon requires ledger as a
76
+ regular file but does not parse its body.
77
+
78
+ Write implementation and deployment plans under `## Steps` and their outcome
79
+ contracts under `## Acceptance criteria`. Give every item a stable level-three
80
+ `I-Sxx`, `I-ACxx`, `D-Sxx`, or `D-ACxx` heading. Each criterion describes both
81
+ the observable outcome and how to prove it. Keep task-list checkboxes out of
82
+ world contracts.
83
+
84
+ Agents mirror those stable IDs and short titles into the required `ledger.md`
85
+ under Implementation and Deployment Steps and Acceptance criteria checklists.
86
+ Update both files together, and reset a checked item when its requirement or
87
+ proof changes materially. Checkboxes record Agent work only, never human
88
+ approval or acceptance.
89
+
90
+ ```yaml
91
+ version: 1
92
+ id: 01M36QGPNTXEPP61DA4KP4AVZF
93
+ alias: publish-documentation
94
+ ```
95
+
96
+ Status may additionally contain canonical `abandoned: true`,
97
+ `approvedRevision`, `implementationAcceptedRevision`, and
98
+ `deploymentAcceptedRevision` in that order. Decisions must bind to their
99
+ corresponding current world revision.
100
+
101
+ For a new scaffold, run `silvermoon create-idea --json`. It generates the ULID,
102
+ four structured documents and alias-less status; it does not stage, commit,
103
+ push, approve, or accept. During initial preparation, complete `Idea.md` while
104
+ keeping the Implementation, Deployment, and ledger placeholders synchronized
105
+ until their lifecycle actions. An Agent may add a concise, unique alias derived
106
+ from the user's request without asking the user to choose a name.
107
+
108
+ ## Adopting from another layout
109
+
110
+ Silvermoon deliberately has no runtime compatibility mode or in-place migration
111
+ command. It recognizes only `.silvermoon/config.yaml` and the fixed nested
112
+ world layout. A repository containing only another configuration or idea layout
113
+ is unconfigured.
114
+
115
+ Prepare one reviewed cutover commit with ordinary repository tools. Preserve
116
+ old Git history, inspect every retained outcome, and record only decisions that
117
+ have explicit evidence for the exact corresponding world revision. Silvermoon
118
+ does not read, merge, move, delete, diagnose, or infer facts from old layouts.
119
+
120
+ Run `silvermoon check --worktree`, stage the candidate, run the staged and
121
+ commit checks, publish non-force, then run the remote check against complete
122
+ primary history.