specsight-skill 0.0.0-stage → 0.3.2
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 +21 -0
- package/README.md +94 -2
- package/index.mjs +56 -0
- package/install.mjs +26 -0
- package/package.json +14 -4
- package/skills/specsight/SKILL.md +62 -0
- package/skills/specsight/reference/canvas-format.md +223 -0
- package/skills/specsight/reference/doc-format.md +68 -0
- package/skills/specsight/reference/recipes.md +165 -0
- package/skills/specsight/scripts/specsight.sh +138 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 raisulkhairi
|
|
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,95 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Specsight
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A personal tool for developers who build projects by vibe coding: see visually whether the flows, PRDs, API contracts, ERDs, and design systems Claude produces are right. It runs on localhost and is not meant to be hosted.
|
|
4
|
+
|
|
5
|
+
Everything is stored as files in the **`.specsight/`** folder of your project. Claude writes those files; you open Specsight in the browser to view and edit them; your edits are saved back to the same files (and tracked by git).
|
|
6
|
+
|
|
7
|
+
## Using it in your project
|
|
8
|
+
|
|
9
|
+
The only thing your project needs is the **`specsight` skill**. Install it from your project folder:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npx specsight-skill
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The installer asks whether to install the skill for this project (`./.claude/skills/`) or for all projects (`~/.claude/skills/`), then prepares the app right away so your first request to Claude doesn't have to wait for a build. Options: `-p` (project), `-g` (global), `-y` (no questions), `--no-setup` (skip app setup). To update, run `npx specsight-skill@latest` again.
|
|
16
|
+
|
|
17
|
+
Other ways:
|
|
18
|
+
|
|
19
|
+
- [skills CLI](https://github.com/vercel-labs/skills): `npx skills add raisulkhairi/specsight --skill specsight -a claude-code` (add `-g` for global).
|
|
20
|
+
- Manual: copy the `skills/specsight/` folder from this repo into `.claude/skills/`.
|
|
21
|
+
|
|
22
|
+
*Formerly called Specloop (and before that, Syntext).* Older projects with a `.specloop/` or `.syntext/` folder are moved to `.specsight/` automatically the first time the skill runs.
|
|
23
|
+
|
|
24
|
+
**Requirements:** Claude Code, git, Node.js 20+ (22.20+ for `npx skills`), and a bash shell. Tested on Linux; macOS should work; Windows via WSL.
|
|
25
|
+
|
|
26
|
+
Then ask Claude, for example: *"create the checkout flow and its PRD in Specsight"*. The skill will:
|
|
27
|
+
|
|
28
|
+
1. clone and build Specsight once into `~/.specsight/app` (requires git and Node.js 20+),
|
|
29
|
+
2. start a server for this project (`http://localhost:8787`, or the next free port; the same port is reused after a restart),
|
|
30
|
+
3. write files in `.specsight/`, check them, and give you a link to them.
|
|
31
|
+
|
|
32
|
+
Contents of `.specsight/`:
|
|
33
|
+
|
|
34
|
+
| Path | Contents |
|
|
35
|
+
| --- | --- |
|
|
36
|
+
| `**/*.canvas.json` | Canvases (flowchart, sequence, ERD, API contract, …). Format: `skills/specsight/reference/canvas-format.md` |
|
|
37
|
+
| `**/*.md` | Docs (Markdown + canvas embeds). Format: `skills/specsight/reference/doc-format.md` |
|
|
38
|
+
| `assets/` | Images pasted onto canvases |
|
|
39
|
+
| `.history/` | The last 20 versions of each file, for recovering overwritten edits (not committed) |
|
|
40
|
+
| `.runtime.json` | Port of the running server (not committed) |
|
|
41
|
+
|
|
42
|
+
When Claude changes a file you have open, the view updates immediately. If you also have unsaved edits, the version on disk is shown and a banner above the file keeps your edits: **Lihat perbedaan** (view diff), **Pakai edit saya** (use my edits: overwrites the file; the overwritten version stays in `.history/`), or **Salin edit saya** (copy my edits). Closing a tab with unsaved edits triggers a browser confirmation.
|
|
43
|
+
|
|
44
|
+
To give Claude feedback, add comments on the canvas. The **Komentar terbuka** (open comments) panel below the Explorer lists every unresolved comment. Then ask Claude to *"check my comments in Specsight"*: the skill runs `feedback`, which prints the open comments and a diff of the files you changed since Claude last read them.
|
|
45
|
+
|
|
46
|
+
> UI labels are quoted as they appear in the app (Indonesian), with an English gloss in parentheses.
|
|
47
|
+
|
|
48
|
+
## Developing Specsight
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
npm install
|
|
52
|
+
npm run dev # web http://localhost:5173 + API for examples/.specsight
|
|
53
|
+
npm test # unit tests (Vitest)
|
|
54
|
+
npm run typecheck
|
|
55
|
+
|
|
56
|
+
# production for a single project
|
|
57
|
+
npm run build && npm start -- --dir /path/to/project/.specsight
|
|
58
|
+
npm run check -- --dir /path/to/project/.specsight # check all files
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Server: `server/` (Express, `127.0.0.1` only). File formats: `src/lib/canvasFile.ts` and `src/lib/docMarkdown.ts`. Skill: `skills/specsight/`.
|
|
62
|
+
|
|
63
|
+
## Features
|
|
64
|
+
- **Explorer**: a tree of the `.specsight/` folder on the left (VS Code style). Folders in the Explorer are folders on disk. Add folders, **Editor** files (`*.canvas.json`), and **Doc** files (`*.md`, rich text with a formatting toolbar; saved as Markdown) via the header buttons or right-click / ⋯. Rename, delete, and drag & drop move files on disk; embeds and links in other files are updated too. URL `#/f/<path>`. Logic in `src/lib/pathTree.ts` and `server/files.ts`
|
|
65
|
+
- **Embed elements in Docs** (PRDs, specs, READMEs): the **Embed** button in the Doc toolbar opens a picker of elements from Editor files in the same project (API contracts, ERDs, folder structures, sequences, swimlanes, frames, code blocks, … or the whole canvas) with a preview. In the Editor, select an element → *Salin kode embed* (copy embed code) icon → paste into a Doc. Embeds are stored as ```` ```embed ```` blocks (`doc:` canvas file path + `node:`) and **do not copy the content**: the Doc preview always renders the latest version, so Editor changes show up in the Doc immediately. API contracts render as HTML cards (text is copyable), other elements as vector SVG (the same renderer as Export). *Buka di Editor* (open in Editor) opens the source file and highlights the element; embeds whose element was deleted are marked *rusak* (broken) and counted in the Doc footer. Logic in `src/lib/embed.ts`
|
|
66
|
+
- Basic flowchart shapes: Start/End, Process, Decision, I/O. Advanced shapes (Document, Database, Delay, etc.) are not offered in the UI but are still rendered for older documents and Mermaid imports. Their definitions live in `shared/shapeKinds.ts`
|
|
67
|
+
- Lines & arrows: step/straight/curved, solid/dashed, arrowhead at end/both ends/none, color, flow animation. A toolbar appears when an arrow is clicked. There is also a free arrow whose ends can be dragged onto two shapes to connect them
|
|
68
|
+
- **Sequence diagrams (UML)**: participants (participant/actor/database/queue) with lifelines, sync/async/reply/self messages, automatic activation bars, `loop`/`alt`/`opt`/`par` fragments, notes (`over`/`left of`/`right of`), `box` to group participants, `create`/`destroy` participants, automatic or manual activation (`+`/`-`, `activate`/`deactivate`), autonumbering. Edit labels by double-clicking, click a message/participant to change direction, type, order; or edit as **Mermaid** text (`sequenceDiagram`) and copy as Mermaid. Logic (parser, layout) in `shared/sequence.ts`
|
|
69
|
+
- **Mermaid import**: paste (Ctrl+V) Mermaid `flowchart`/`graph` or `sequenceDiagram` text straight onto the canvas (```` ```mermaid ```` blocks from a README work too), or use **Import → Mermaid**. Node shapes (including the v11 `@{ shape }` syntax), arrow labels, dashed/headless/bidirectional lines, colors from `classDef`/`style`, and front-matter titles are all read; the new diagram is placed and laid out to the right of the existing content (one undo step). Parser in `shared/mermaid.ts`
|
|
70
|
+
- **Frames / groups**: titled boxes behind their contents (the *Frame / Grup* tile, or select several nodes and press **Ctrl+G**; **Ctrl+Shift+G** ungroups without deleting the contents). Nodes dropped into a frame become members and move with it; frames can nest, be resized, colored, and connected with arrows. Auto layout keeps members inside their frame. Mermaid `subgraph`s are imported as frames
|
|
71
|
+
- **Presentation mode** (the *Presentasi* button at the top): walks the flow step by step following the arrows — the "Yes" branch first, loops shown as "back to …", and sequence diagrams message by message. The active node lights up, the rest are dimmed, and the camera follows. Arrows leaving an **API contract response** highlight that response on the card (the rest of the card is dimmed), the camera frames the response row + its target, branches are ordered from the lowest status (2xx first), and step labels are generated automatically, e.g. `400 Bad Request → …`. Navigate with ← → / Space, **P** to autoplay, fullscreen, **Esc** to exit. Starts from the selected node if any. Does not modify the document
|
|
72
|
+
- **Database / ERD**: table nodes (columns, types, PK/FK/UQ/nullable) and relations in crow's foot notation (1–1, 1–N, N–1, N–N, optional). Drag from the handle at the edge of a column row to a column in another table to create an FK → PK relation attached to its row. Paste SQL `CREATE TABLE` (or Mermaid `erDiagram`) straight onto the canvas to import a schema — FKs to existing tables are connected too. Copy a table as SQL, or Export → SQL. *Database (ERD)* template. Parser in `shared/erd.ts`
|
|
73
|
+
- **Swimlanes** (flows across roles/departments): a pool of horizontal lanes (left → right flow) or vertical lanes (top → bottom). Drop a node onto a lane band to add it; the pool carries its contents when moved. Add/remove lanes, rename by double-clicking, drag the line between lanes to change their thickness (lanes below shift along), switch orientation, and *Rapikan* (tidy up) lays out the flow with every node kept in its lane. There is a *Swimlane* template (Customer / System / Warehouse)
|
|
74
|
+
- **Folder structure**: a folder & file tree diagram with branch lines (├ └ │), per-file-type icons, and comments. Double-click it to write it as indented text (names ending in `/` are folders, `# comment` after a name; Tab/Shift+Tab adjust indentation, Enter keeps indentation). Paste the output of the `tree` command straight onto the canvas, or copy it back as `tree` text. Node height follows the number of lines. Parser in `src/lib/fileTree.ts`
|
|
75
|
+
- **API contract**: a contract card for one endpoint — method (color per method), URL with `{id}` / `:id` path parameters highlighted, description, headers & query params (`Key: value # note`), request body, and a list of responses per status code (200/201/204/400/401/403/404/422/500, color per status class) with JSON-highlighted example bodies. Double-click to open the edit form (JSON validation & formatting, one-click add response, Ctrl+Enter to save). Copy as **cURL** or **Markdown** (ready to paste into a Doc), or copy the body **per response** via the *Salin* (copy) button that appears on hover over a status row (also in Doc embeds). Each response has **its own connection handles** on the left & right of its status row: drag an arrow from `201` to the success step and from `400` to the error handling; the arrow sticks to that response row (moves when the card content changes, is removed when the response is deleted, and is included in exports). Included in SVG/PNG/PDF export. Logic in `src/lib/apiContract.ts`
|
|
76
|
+
- **Align & distribute**: select ≥ 2 nodes (Shift+click or drag a marquee) → selection toolbar: align left/center/right/top/middle/bottom, distribute horizontally/vertically (≥ 3 nodes), group, duplicate, delete. Figma-style shortcuts: Alt+A/H/D, Alt+W/V/S, Alt+Shift+H/V. Frames carry their contents
|
|
77
|
+
- **Comments** (like Figma comments): comments on a specific element appear as a **pin** (message-count badge, ✓ when resolved) beside the element with a leader line; **hover** the pin to read the thread, **click** it to keep the card open. Reply in the reply box (**Enter** = save). Mark as *Selesai* (resolved; the pin dims and shows ✓); a new reply reopens it. Messages can be **edited** (✏️ → the message loads into the same input as replies; Enter saves · Esc cancels and restores the reply draft; marked *diedit* (edited)) or **deleted** (🗑, Ctrl+Z to undo; the comment is removed when no messages remain). Created from the *Komentar* (comment) tile. Comments are not included in exports / embeds. Comments **stick to their element**: they move when the element is moved / laid out, and a pin can't be more than 64 px from the element's edge (older comments that drifted too far are pulled closer when the file is opened). Logic in `src/lib/comments.ts`
|
|
78
|
+
- Code blocks (9 languages, syntax highlighting, copy; width & height are resizable; lines longer than the block width **wrap automatically** (soft wrap, line numbers preserved) so there's no horizontal scrolling — SVG/PNG/PDF export wraps lines the same way; a new code block's initial width fits its code (max. 720 px). Logic in `src/lib/codeSize.ts`), text, sticky notes
|
|
79
|
+
- Drag & drop, connecting arrows (click an arrow, then **drag the handle at its head / tail** to another element to move the connection — including API response handles / ERD columns; releasing on empty space cancels; **double-click an arrow** to add / change its label — Enter saves, Esc cancels; a single click only selects the arrow), double-click to edit text, floating toolbar (color, shape, duplicate, delete)
|
|
80
|
+
- **Data always stays consistent**: deleting a node (Delete or the delete button) also removes its id from swimlane lanes, frame members, comment targets, and attached arrows; a deleted container hands its contents to its parent container. Older documents are cleaned up when opened. One delete = one undo step. Logic in `src/lib/integrity.ts`
|
|
81
|
+
- Undo/redo (Ctrl+Z / Ctrl+Y), copy/paste (Ctrl+C / Ctrl+V), duplicate (Ctrl+D), auto layout (dagre), minimap
|
|
82
|
+
- **Images**: paste (Ctrl+V) screenshots/images, image URLs, `<svg>` markup (e.g. *Copy as SVG* from Figma, Lucide/Heroicons icons), or `data:image/…` data URLs. The format follows the clipboard: *Copy as SVG* → vector image, *Copy as PNG* → PNG. Logic in `src/lib/pasteSvg.ts`. You can also drag & drop files, or use the **Uploads** tab. Images can be resized (aspect ratio locked), given rounded corners, replaced, downloaded, and connected with arrows.
|
|
83
|
+
- Templates (offered when the canvas is empty), autosave to files (`.specsight/`; images in `.specsight/assets/`), PNG/JSON export (images embedded), JSON import (becomes a new canvas file)
|
|
84
|
+
- **Vector SVG & PDF export**: every node is redrawn as pure SVG (no `foreignObject`/CSS/`marker`) so it can be opened & edited in Figma, Illustrator, Inkscape; code blocks keep their syntax highlighting. One-click PDF with Inter & JetBrains Mono fonts embedded (text is selectable). The *Hanya yang dipilih* (selection only) option applies to PNG/SVG/PDF. Renderer in `src/lib/svgExport.ts`; OFL fonts in `public/fonts`
|
|
85
|
+
- **Element links → reference in comments**: the *Salin link elemen* (copy element link, 🔗 icon) button in the element toolbar — or in the multi-selection toolbar for several elements at once — copies a `…/#/f/<path>?node=<id>` URL. Paste it (Ctrl+V) into a comment reply → it becomes `@Label` (stored as `@[Label](id)`) and shows as a clickable chip (struck through if the element was deleted). The link can also be opened directly in the browser to open the file & highlight the element. Links from other files are not converted. Logic in `src/lib/elementLink.ts` & `src/lib/mentions.ts`
|
|
86
|
+
|
|
87
|
+
## Releasing
|
|
88
|
+
|
|
89
|
+
1. Bump the version to the same number in three places: `package.json`, `cli/package.json`, and `VERSION` in `skills/specsight/scripts/specsight.sh` (enforced by the `cli/install.test.mjs` test).
|
|
90
|
+
2. Commit, then `git tag vX.Y.Z && git push origin main vX.Y.Z`.
|
|
91
|
+
3. Publish the installer: `cd cli && npm publish`. The skill is bundled automatically on `npm pack`/`publish`.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MIT. See [LICENSE](LICENSE).
|
package/index.mjs
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// npx specsight-skill: pasang skill Specsight untuk Claude Code, lalu siapkan app-nya.
|
|
3
|
+
import { spawnSync } from 'node:child_process'
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
5
|
+
import { homedir } from 'node:os'
|
|
6
|
+
import { createInterface } from 'node:readline/promises'
|
|
7
|
+
import { fileURLToPath } from 'node:url'
|
|
8
|
+
import { installSkill, parseArgs, skillDest } from './install.mjs'
|
|
9
|
+
|
|
10
|
+
const here = (p) => fileURLToPath(new URL(p, import.meta.url))
|
|
11
|
+
const { version } = JSON.parse(readFileSync(here('./package.json'), 'utf8'))
|
|
12
|
+
// di paket npm skill ikut dibundel di ./skills; saat dijalankan dari repo, pakai ../skills
|
|
13
|
+
const SRC = [here('./skills/specsight'), here('../skills/specsight')].find((p) => existsSync(p))
|
|
14
|
+
|
|
15
|
+
const HELP = `specsight-skill ${version}: pasang skill Specsight untuk Claude Code
|
|
16
|
+
|
|
17
|
+
npx specsight-skill tanya: project ini atau semua project
|
|
18
|
+
npx specsight-skill -p pasang di project ini (./.claude/skills/specsight)
|
|
19
|
+
npx specsight-skill -g pasang untuk semua project (~/.claude/skills/specsight)
|
|
20
|
+
|
|
21
|
+
--no-setup jangan siapkan app sekarang (Claude menyiapkannya saat pertama dipakai)
|
|
22
|
+
-y tanpa pertanyaan (default: project)
|
|
23
|
+
`
|
|
24
|
+
|
|
25
|
+
async function askScope() {
|
|
26
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
27
|
+
try {
|
|
28
|
+
console.log('Pasang skill Specsight untuk:\n 1) project ini (./.claude/skills)\n 2) semua project (~/.claude/skills)')
|
|
29
|
+
const a = (await rl.question('Pilih [1]: ')).trim()
|
|
30
|
+
return a === '2' ? 'global' : 'project'
|
|
31
|
+
} finally { rl.close() }
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function main() {
|
|
35
|
+
let opts
|
|
36
|
+
try { opts = parseArgs(process.argv.slice(2)) } catch (e) { console.error(`specsight: ${e.message}`); process.exit(1) }
|
|
37
|
+
if (opts.help) { console.log(HELP); return }
|
|
38
|
+
if (!SRC) { console.error('specsight: file skill tidak ditemukan di paket ini'); process.exit(1) }
|
|
39
|
+
|
|
40
|
+
const scope = opts.scope ?? (opts.yes || !process.stdin.isTTY ? 'project' : await askScope())
|
|
41
|
+
const dest = skillDest(scope, process.cwd(), homedir())
|
|
42
|
+
const result = installSkill(SRC, dest)
|
|
43
|
+
console.log(`✓ skill specsight ${version} ${result === 'updated' ? 'diperbarui' : 'terpasang'} → ${dest}`)
|
|
44
|
+
|
|
45
|
+
if (opts.setup) {
|
|
46
|
+
console.log('Menyiapkan app Specsight (sekali per komputer, ±1 menit pertama kali) …')
|
|
47
|
+
const r = spawnSync('bash', [`${dest}/scripts/specsight.sh`, 'ensure'], { stdio: 'inherit' })
|
|
48
|
+
if (r.status !== 0) console.error('specsight: app belum siap. Skill tetap terpasang; Claude akan mencoba lagi saat pertama dipakai.')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
console.log(`
|
|
52
|
+
Selesai. Buka Claude Code ${scope === 'global' ? 'di project mana pun' : 'di project ini'} lalu minta, misalnya:
|
|
53
|
+
"buatkan flow checkout dan PRD-nya di Specsight"`)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
main()
|
package/install.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { chmodSync, cpSync, existsSync, rmSync } from 'node:fs'
|
|
2
|
+
import { join } from 'node:path'
|
|
3
|
+
|
|
4
|
+
/** Salin folder skill ke dest. Folder lama diganti seluruhnya, jadi pasang ulang = update. */
|
|
5
|
+
export function installSkill(src, dest) {
|
|
6
|
+
const existed = existsSync(dest)
|
|
7
|
+
rmSync(dest, { recursive: true, force: true })
|
|
8
|
+
cpSync(src, dest, { recursive: true })
|
|
9
|
+
chmodSync(join(dest, 'scripts/specsight.sh'), 0o755)
|
|
10
|
+
return existed ? 'updated' : 'installed'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const skillDest = (scope, cwd, home) => join(scope === 'global' ? home : cwd, '.claude/skills/specsight')
|
|
14
|
+
|
|
15
|
+
export function parseArgs(argv) {
|
|
16
|
+
const o = { scope: undefined, setup: true, yes: false, help: false }
|
|
17
|
+
for (const a of argv) {
|
|
18
|
+
if (a === '-g' || a === '--global') o.scope = 'global'
|
|
19
|
+
else if (a === '-p' || a === '--project') o.scope = 'project'
|
|
20
|
+
else if (a === '--no-setup') o.setup = false
|
|
21
|
+
else if (a === '-y' || a === '--yes') o.yes = true
|
|
22
|
+
else if (a === '-h' || a === '--help') o.help = true
|
|
23
|
+
else throw new Error(`opsi tidak dikenal: ${a} (lihat --help)`)
|
|
24
|
+
}
|
|
25
|
+
return o
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "specsight-skill",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
}
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "Pasang skill Specsight untuk Claude Code: flow, PRD, ERD, dan API contract yang ditulis Claude, dilihat dan diedit di browser (localhost).",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "specsight-skill": "index.mjs" },
|
|
7
|
+
"files": ["index.mjs", "install.mjs", "skills"],
|
|
8
|
+
"scripts": {
|
|
9
|
+
"prepack": "rm -rf skills && mkdir -p skills && cp -r ../skills/specsight skills/ && cp ../LICENSE ../README.md .",
|
|
10
|
+
"postpack": "rm -rf skills LICENSE README.md"
|
|
11
|
+
},
|
|
12
|
+
"engines": { "node": ">=20" },
|
|
13
|
+
"keywords": ["claude-code", "claude", "skill", "flowchart", "prd", "diagram"],
|
|
14
|
+
"repository": { "type": "git", "url": "git+https://github.com/raisulkhairi/specsight.git", "directory": "cli" },
|
|
15
|
+
"license": "MIT"
|
|
16
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: specsight
|
|
3
|
+
description: Show this project's flows, flowcharts, feature flows, sequence diagrams, ERDs/database schemas, API contracts, PRDs, specs, or design system visually in Specsight (a canvas + Doc editor on localhost). Use when the developer asks to create/update such diagrams or documents, asks to "show it in Specsight", or asks Claude to read the comments/edits they made in Specsight.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Specsight
|
|
7
|
+
|
|
8
|
+
Specsight shows the files in the `.specsight/` folder (at the project root) as canvases and documents in the browser. Claude writes the files; the developer views and edits them in the browser; edits are saved back to the same files.
|
|
9
|
+
|
|
10
|
+
- `*.canvas.json`: canvases (flowchart, sequence, ERD, API contract, swimlane, …). Format: [reference/canvas-format.md](reference/canvas-format.md)
|
|
11
|
+
- `*.md`: Docs (PRD, spec, design system). Format: [reference/doc-format.md](reference/doc-format.md)
|
|
12
|
+
- How to build commonly requested content: [reference/recipes.md](reference/recipes.md)
|
|
13
|
+
|
|
14
|
+
`S` below is `scripts/specsight.sh` in this skill's folder (the folder containing this SKILL.md, given as the *base directory* when the skill is loaded). Usually `.claude/skills/specsight/scripts/specsight.sh` in the project, or `~/.claude/skills/specsight/scripts/specsight.sh` when installed globally.
|
|
15
|
+
|
|
16
|
+
## Steps
|
|
17
|
+
|
|
18
|
+
1. **Set up Specsight** (once per device; afterwards it only checks for updates):
|
|
19
|
+
`bash S ensure`
|
|
20
|
+
The script needs git and Node.js 20+, and clones Specsight into `~/.specsight/app`. If it fails, pass the error message on to the developer.
|
|
21
|
+
2. **Start the server** for this project:
|
|
22
|
+
`bash S start "$PWD"`
|
|
23
|
+
The script prints the URL, e.g. `http://localhost:8787`. A server already running for this project is reused, and the same port is reused after a restart. If the script says the port changed, old links no longer work: give the developer the new link.
|
|
24
|
+
3. **Write or change files** in `.specsight/` following the reference. Group them in folders, for example:
|
|
25
|
+
- `flows/` for flowcharts,
|
|
26
|
+
- `api/` for API contracts,
|
|
27
|
+
- `data/` for ERDs,
|
|
28
|
+
- `docs/` for PRDs.
|
|
29
|
+
4. **Check:**
|
|
30
|
+
`bash S check "$PWD"`
|
|
31
|
+
Fix every error (✗), including Doc content the editor doesn't support (it will be lost as soon as the developer edits the Doc). A warning (⚠) means something was fixed or dropped automatically; fix that too if it isn't what you intended.
|
|
32
|
+
`check` also records the current file contents as read by you, so your own writes don't show up in `feedback`.
|
|
33
|
+
5. **Give the developer a direct link** to the file: `<URL>/#/f/<path>`, e.g. `http://localhost:8787/#/f/flows/checkout.canvas.json`. Spaces in the path are written as `%20`. Ask the developer to review it and leave comments in the browser.
|
|
34
|
+
|
|
35
|
+
## Safe editing rules
|
|
36
|
+
|
|
37
|
+
- **Re-read a file right before changing it.** Don't rely on an earlier read, because the developer may have just moved a node, added a comment, or typed in a Doc in the browser. Change only what's needed, and keep existing `position`s, sizes, and comments.
|
|
38
|
+
- **Don't delete the developer's comments** (`comment` nodes) unless asked. Read their `data.thread` as feedback.
|
|
39
|
+
- **If the developer's edits were overwritten,** previous versions are in `.specsight/.history/<path>/` (the last 20 versions per file). Copy back what's needed.
|
|
40
|
+
- **When renaming or moving a file,** update its references yourself: `doc:` in embed blocks and `#/f/<path>` links in other files. Renames done through the Explorer in the browser update references automatically.
|
|
41
|
+
- **Don't modify** `.specsight/.runtime.json` or `.specsight/.gitignore`.
|
|
42
|
+
|
|
43
|
+
## Reading feedback from the browser
|
|
44
|
+
|
|
45
|
+
When the developer says "check my comments in Specsight" or "I changed it in Specsight", run:
|
|
46
|
+
`bash S feedback "$PWD"`
|
|
47
|
+
|
|
48
|
+
The output contains:
|
|
49
|
+
- **open comments** across all canvases: comment id, the element commented on, and its thread,
|
|
50
|
+
- **files changed by the developer** since you last ran `check` or `feedback`, with a line-by-line diff.
|
|
51
|
+
|
|
52
|
+
Then:
|
|
53
|
+
- do what the comments ask, and re-read a file before changing it;
|
|
54
|
+
- once a comment is handled, add a reply to `data.thread` (`{ "id": "m<n>", "text": "…", "at": <epoch ms> }`) and set `"resolved": true`, so it drops off the open list;
|
|
55
|
+
- `git diff .specsight/` is still useful for seeing all changes since the last commit.
|
|
56
|
+
|
|
57
|
+
## Other commands
|
|
58
|
+
|
|
59
|
+
- `bash S stop "$PWD"`: stop this project's server.
|
|
60
|
+
- `bash S feedback "$PWD"`: open comments and changes from the developer (see above).
|
|
61
|
+
- `SPECSIGHT_REPO=<url or path>`: change the clone source, e.g. to test a local version.
|
|
62
|
+
- `SPECSIGHT_REF=<tag or branch>`: use a different app version. Defaults to the version written in `scripts/specsight.sh` (`VERSION`), so the skill and app always match.
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# Canvas file format (`*.canvas.json`)
|
|
2
|
+
|
|
3
|
+
One file holds one canvas. Its path is relative to `.specsight/`, e.g. `flows/login.canvas.json`.
|
|
4
|
+
|
|
5
|
+
```json
|
|
6
|
+
{
|
|
7
|
+
"specsight": 1,
|
|
8
|
+
"name": "Login",
|
|
9
|
+
"nodes": [
|
|
10
|
+
{ "id": "start", "type": "shape", "data": { "shape": "terminal", "label": "Start" } },
|
|
11
|
+
{ "id": "valid", "type": "shape", "data": { "shape": "decision", "label": "Valid?" } }
|
|
12
|
+
],
|
|
13
|
+
"edges": [
|
|
14
|
+
{ "id": "e1", "source": "start", "target": "valid" }
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## General rules
|
|
20
|
+
|
|
21
|
+
- **Write only what's needed.** Omitted fields get defaults: colors, sizes, and the heights of tables/API/tree/sequence nodes are computed from their content.
|
|
22
|
+
- **`position` can be omitted.** Nodes without a position are laid out automatically the first time the file is opened in the browser, and their positions are then saved to the file. Nodes that already have a position aren't moved. So for a new diagram, leave all positions out.
|
|
23
|
+
- **Node ids must be unique and readable** (`start`, `login_api`, `tbl_users`). Ids are used by edges, Doc embeds (`node: login_api`), and element links.
|
|
24
|
+
- **An edge** only needs `source` and `target`. Without an `id`, its id is automatically `e_<source>_<target>`.
|
|
25
|
+
- **Don't write** `measured`, `selected`, `dragging`, or `internals`. Those fields belong to the editor and are dropped.
|
|
26
|
+
- After the developer edits in the browser, the file is rewritten neatly (2-space indentation). It stays compact: only fields that differ from the default are written.
|
|
27
|
+
- Invalid nodes (unknown type, duplicate id) and edges to nonexistent nodes are **dropped**. Check with `specsight.sh check`.
|
|
28
|
+
|
|
29
|
+
## Shape (flowchart)
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{ "id": "pay", "type": "shape", "data": { "shape": "process", "label": "Process payment" } }
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`shape` can be:
|
|
36
|
+
- `terminal`: start/end
|
|
37
|
+
- `process`: a step
|
|
38
|
+
- `decision`: yes/no, with exactly two labeled outgoing edges
|
|
39
|
+
- `io`: user input/output
|
|
40
|
+
- `document`, `multidoc`
|
|
41
|
+
- `database`
|
|
42
|
+
- `subroutine`: a sub-process
|
|
43
|
+
- `manual_input`, `preparation`, `manual_op`
|
|
44
|
+
- `delay`
|
|
45
|
+
- `display`: something shown to the user
|
|
46
|
+
- `connector`, `offpage`
|
|
47
|
+
- `merge`
|
|
48
|
+
- `annotation`
|
|
49
|
+
|
|
50
|
+
Prefer the four basic shapes (`terminal`, `process`, `decision`, `io`). `color` is optional and is a hex value, e.g. `"#10b981"`.
|
|
51
|
+
|
|
52
|
+
## Edge
|
|
53
|
+
|
|
54
|
+
```json
|
|
55
|
+
{
|
|
56
|
+
"nodes": [
|
|
57
|
+
{ "id": "a", "type": "shape", "data": { "shape": "decision", "label": "In stock?" } },
|
|
58
|
+
{ "id": "b", "type": "shape", "data": { "shape": "process", "label": "Ship" } },
|
|
59
|
+
{ "id": "c", "type": "shape", "data": { "shape": "display", "label": "Out of stock", "color": "#ef4444" } }
|
|
60
|
+
],
|
|
61
|
+
"edges": [
|
|
62
|
+
{ "id": "yes", "source": "a", "target": "b", "label": "Yes", "data": { "color": "#10b981" } },
|
|
63
|
+
{ "id": "no", "source": "a", "target": "c", "label": "No", "data": { "dashed": true } }
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`data` fields (all optional):
|
|
69
|
+
|
|
70
|
+
| Field | Values | Default |
|
|
71
|
+
| --- | --- | --- |
|
|
72
|
+
| `line` | `step`, `straight`, `curve` | `step` |
|
|
73
|
+
| `dashed` | `true` / `false` | `false` |
|
|
74
|
+
| `arrow` | `end`, `both`, `none` | `end` |
|
|
75
|
+
| `color` | hex | `#8b93a7` |
|
|
76
|
+
| `animated` | `true` / `false` | `false` |
|
|
77
|
+
|
|
78
|
+
## Sequence diagram
|
|
79
|
+
|
|
80
|
+
Write the source as a Mermaid `sequenceDiagram` (without the `sequenceDiagram` line) in `data.source`:
|
|
81
|
+
|
|
82
|
+
```json
|
|
83
|
+
{ "id": "seq_login", "type": "sequence", "data": { "source": "title: Login\nactor User\nparticipant Web\nparticipant API\ndatabase DB\nUser->>Web: Enter email & password\nWeb->>API: POST /login\nAPI->>DB: find user\nDB-->>API: user\nalt password correct\n API-->>Web: 200 + token\nelse wrong\n API-->>Web: 401\nend\nWeb-->>User: result" } }
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Mermaid rules:
|
|
87
|
+
- **Participants:** `participant`, `actor`, `database`, or `queue`.
|
|
88
|
+
- **Messages:**
|
|
89
|
+
- `->>`: call,
|
|
90
|
+
- `-->>`: reply,
|
|
91
|
+
- `-)`: async/event.
|
|
92
|
+
- **Fragments:** `alt`/`else`/`end`, `opt`, `loop`, `par`.
|
|
93
|
+
- **Notes:** `Note over A,B: text`.
|
|
94
|
+
|
|
95
|
+
After the developer edits a sequence in the browser, the file stores structured data (`participants`, `messages`) instead of `source`.
|
|
96
|
+
|
|
97
|
+
## Table (ERD)
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"nodes": [
|
|
102
|
+
{ "id": "users", "type": "table", "data": { "name": "users", "columns": [
|
|
103
|
+
{ "name": "id", "type": "bigserial", "pk": true },
|
|
104
|
+
{ "name": "email", "type": "varchar(255)", "unique": true }
|
|
105
|
+
] } },
|
|
106
|
+
{ "id": "orders", "type": "table", "data": { "name": "orders", "columns": [
|
|
107
|
+
{ "name": "id", "type": "bigserial", "pk": true },
|
|
108
|
+
{ "name": "user_id", "type": "bigint", "fk": true },
|
|
109
|
+
{ "name": "note", "type": "text", "nullable": true }
|
|
110
|
+
] } }
|
|
111
|
+
],
|
|
112
|
+
"edges": [
|
|
113
|
+
{ "id": "orders_users", "source": "orders", "target": "users", "data": { "relation": "n-1", "sourceColumn": "c_user_id", "targetColumn": "c_id" } }
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- **Column ids** are automatically `c_<column name>`. Use them in `sourceColumn`/`targetColumn` so the relation line attaches to the column row.
|
|
119
|
+
- **`relation`:**
|
|
120
|
+
- `1-1`,
|
|
121
|
+
- `1-n`,
|
|
122
|
+
- `n-1`: many source rows → one target row,
|
|
123
|
+
- `n-n`.
|
|
124
|
+
- **Optional column fields:** `pk`, `fk`, `unique`, `nullable`, `note`.
|
|
125
|
+
|
|
126
|
+
## API contract
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{ "id": "api_login", "type": "api", "data": {
|
|
130
|
+
"title": "Login", "method": "POST", "url": "/api/v1/login",
|
|
131
|
+
"description": "Exchange email & password for a token.",
|
|
132
|
+
"headers": "Content-Type: application/json",
|
|
133
|
+
"query": "",
|
|
134
|
+
"body": "{\n \"email\": \"jane@mail.com\",\n \"password\": \"secret123\"\n}",
|
|
135
|
+
"responses": [
|
|
136
|
+
{ "status": 200, "body": "{\n \"token\": \"eyJ...\"\n}" },
|
|
137
|
+
{ "status": 401, "description": "Wrong email or password", "body": "{\n \"error\": \"INVALID_CREDENTIALS\"\n}" }
|
|
138
|
+
]
|
|
139
|
+
} }
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
- **`headers` and `query`:** one entry per line, `Key: value # note`.
|
|
143
|
+
- **`responses`:** `description` defaults from the status (200 → OK), and ids are automatically `<node>_r1`, `<node>_r2`, and so on.
|
|
144
|
+
|
|
145
|
+
## Folder structure (tree)
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{ "id": "structure", "type": "tree", "data": { "title": "Project structure", "source": "app/\n src/\n routes/\n auth.ts # login & register\n db.ts\n package.json" } }
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
2-space indentation. A trailing `/` marks a folder. `# text` becomes a note.
|
|
152
|
+
|
|
153
|
+
## Swimlane
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"nodes": [
|
|
158
|
+
{ "id": "order", "type": "shape", "data": { "shape": "process", "label": "Place order" } },
|
|
159
|
+
{ "id": "check", "type": "shape", "data": { "shape": "decision", "label": "In stock?" } },
|
|
160
|
+
{ "id": "lanes", "type": "swimlane", "data": { "title": "Ordering", "lanes": [
|
|
161
|
+
{ "label": "Customer", "members": ["order"] },
|
|
162
|
+
{ "label": "System", "members": ["check"] }
|
|
163
|
+
] } }
|
|
164
|
+
],
|
|
165
|
+
"edges": [{ "id": "e1", "source": "order", "target": "check" }]
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
- Each lane has a `label` and `members` (ids of the nodes that actor handles).
|
|
170
|
+
- `orientation` can be `horizontal` (default) or `vertical`.
|
|
171
|
+
|
|
172
|
+
## Frame (group)
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"nodes": [
|
|
177
|
+
{ "id": "api_gw", "type": "shape", "data": { "shape": "process", "label": "API Gateway" } },
|
|
178
|
+
{ "id": "auth_svc", "type": "shape", "data": { "shape": "process", "label": "Auth service" } },
|
|
179
|
+
{ "id": "backend", "type": "frame", "data": { "title": "Backend", "members": ["api_gw", "auth_svc"] } }
|
|
180
|
+
],
|
|
181
|
+
"edges": [{ "id": "e1", "source": "api_gw", "target": "auth_svc" }]
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Use frames for architecture layers or process phases. Not needed for small diagrams (fewer than 6 nodes).
|
|
186
|
+
|
|
187
|
+
## Code block
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{ "id": "hash_pw", "type": "code", "data": { "title": "auth.ts", "language": "typescript", "code": "export const hash = (pw: string) => bcrypt.hash(pw, 12)\n" } }
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
`language` can be `javascript`, `typescript`, `python`, `java`, `cpp`, `sql`, `html`, `css`, or `json`.
|
|
194
|
+
|
|
195
|
+
## Sticky note, text, comment
|
|
196
|
+
|
|
197
|
+
```json
|
|
198
|
+
{ "id": "note", "type": "sticky", "data": { "text": "Rate limit: 5x / 15 minutes", "color": "#fde68a" } }
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
```json
|
|
202
|
+
{ "id": "heading", "type": "text", "data": { "text": "Login Flow", "fontSize": 28 } }
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"nodes": [
|
|
208
|
+
{ "id": "check", "type": "shape", "data": { "shape": "decision", "label": "Token valid?" } },
|
|
209
|
+
{ "id": "question", "type": "comment", "data": { "target": "check", "text": "Should we check expiry too?" } }
|
|
210
|
+
],
|
|
211
|
+
"edges": []
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- **A comment with a `target`** attaches to that node.
|
|
216
|
+
- **The developer's replies** are stored in `data.thread` (`[{ "id", "text", "at" }]`). Read this thread for feedback.
|
|
217
|
+
- **Element references** inside comment text look like `@[Label](node_id)`.
|
|
218
|
+
|
|
219
|
+
## Image
|
|
220
|
+
|
|
221
|
+
`{ "type": "image", "data": { "imageId": "img_abc.png", "name": "mockup.png" }, "width": 480, "height": 300 }`
|
|
222
|
+
|
|
223
|
+
The image file lives at `.specsight/assets/<imageId>`. Images are usually added by the developer by pasting in the browser.
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# Doc format (`*.md`)
|
|
2
|
+
|
|
3
|
+
A Doc is a plain GFM Markdown file in `.specsight/`. It reads fine on GitHub and in other editors.
|
|
4
|
+
|
|
5
|
+
## Supported by the editor
|
|
6
|
+
|
|
7
|
+
- Headings `#` through `######`, paragraphs, **bold**, *italic*, ~~strikethrough~~, `code`
|
|
8
|
+
- `-` and `1.` lists, nested with 2-space indentation
|
|
9
|
+
- Checklists `- [ ]` / `- [x]`
|
|
10
|
+
- GFM tables
|
|
11
|
+
- Blockquotes `>` and rules `---`
|
|
12
|
+
- Code blocks with a language: ```` ```ts ````
|
|
13
|
+
- Links `[text](url)`
|
|
14
|
+
|
|
15
|
+
### Extra formatting (HTML snippets)
|
|
16
|
+
|
|
17
|
+
Formatting that Markdown lacks is written exactly in these forms:
|
|
18
|
+
|
|
19
|
+
| Format | Write |
|
|
20
|
+
| --- | --- |
|
|
21
|
+
| Text color | `<span style="color:#ef4444">text</span>` |
|
|
22
|
+
| Font size | `<span style="font-size:18px">text</span>` |
|
|
23
|
+
| Color + size | `<span style="color:#ef4444;font-size:18px">text</span>` |
|
|
24
|
+
| Highlight | `<mark style="background:#fde68a">text</mark>` |
|
|
25
|
+
| Underline | `<u>text</u>` |
|
|
26
|
+
| Center/right align | `<p align="center">text</p>`, `<h2 align="right">Heading</h2>` |
|
|
27
|
+
|
|
28
|
+
Colors are always lowercase hex.
|
|
29
|
+
|
|
30
|
+
## Embedding canvas elements
|
|
31
|
+
|
|
32
|
+
Parts of a canvas can be shown directly in a Doc. They always show the latest version of the canvas file:
|
|
33
|
+
|
|
34
|
+
````markdown
|
|
35
|
+
## Login flow
|
|
36
|
+
|
|
37
|
+
```embed
|
|
38
|
+
doc: flows/login.canvas.json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Endpoint contract
|
|
42
|
+
|
|
43
|
+
```embed
|
|
44
|
+
doc: api/auth.canvas.json
|
|
45
|
+
node: api_login
|
|
46
|
+
```
|
|
47
|
+
````
|
|
48
|
+
|
|
49
|
+
- `doc:` is the canvas file path, relative to `.specsight/`.
|
|
50
|
+
- `node:` is the element id. Without `node:`, the whole canvas is shown.
|
|
51
|
+
- Embeds are most useful for API contracts, ERD tables, sequences, and flowcharts.
|
|
52
|
+
|
|
53
|
+
## Links to other files or elements
|
|
54
|
+
|
|
55
|
+
```markdown
|
|
56
|
+
See the [login flow](#/f/flows/login.canvas.json) and the [validation step](#/f/flows/login.canvas.json?node=valid).
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Link paths are encoded per segment; spaces are written as `%20`. Don't write `http://localhost:…` because the server port can change.
|
|
60
|
+
|
|
61
|
+
## Not supported (lost when the developer edits the Doc)
|
|
62
|
+
|
|
63
|
+
- Markdown images `![]()`
|
|
64
|
+
- Footnotes `[^1]`
|
|
65
|
+
- Reference-style link definitions `[x]: url`
|
|
66
|
+
- HTML other than the snippets above
|
|
67
|
+
|
|
68
|
+
`check` flags this content as an error. If it remains, the browser shows a warning and asks for confirmation before saving. Avoid it. For images, ask the developer to paste them onto a canvas and embed the image node.
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Recipes
|
|
2
|
+
|
|
3
|
+
How to build commonly requested content. All files are written to `.specsight/` at the project root.
|
|
4
|
+
|
|
5
|
+
## Principles of a good diagram
|
|
6
|
+
|
|
7
|
+
- **Basic flowchart shapes:** `terminal` for Start/End, `process` for steps, `decision` for yes/no questions, `io` for user input/output.
|
|
8
|
+
- **A decision** has exactly two labeled outgoing edges (`Yes`/`No`).
|
|
9
|
+
- **Labels** are short and concrete. Aim for 5–15 nodes per canvas; split large processes across several canvases and link them with `#/f/...` links in a Doc.
|
|
10
|
+
- **Colors carry meaning**; use them consistently:
|
|
11
|
+
- success path green `#10b981`,
|
|
12
|
+
- errors red `#ef4444`,
|
|
13
|
+
- external systems cyan `#06b6d4`.
|
|
14
|
+
- **Dashed lines** (`"dashed": true`) for optional, async, or background flows.
|
|
15
|
+
- **Pick the diagram type that fits the content:**
|
|
16
|
+
- sequence for "who calls whom" over time (API request/response, OAuth, payment callbacks, queues),
|
|
17
|
+
- swimlane for processes involving several roles (customer/system/admin),
|
|
18
|
+
- frame for grouping architecture layers.
|
|
19
|
+
- **When changing an existing diagram:** read the latest file, reuse existing node ids, and keep any `position` and `width`/`height` the developer has set.
|
|
20
|
+
|
|
21
|
+
## Feature flow
|
|
22
|
+
|
|
23
|
+
1. Read the feature's code (routes, handlers, components) so the flow matches the implementation, not a guess.
|
|
24
|
+
2. Write `flows/<feature>.canvas.json` without positions. For example:
|
|
25
|
+
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"specsight": 1,
|
|
29
|
+
"name": "Checkout",
|
|
30
|
+
"nodes": [
|
|
31
|
+
{ "id": "start", "type": "shape", "data": { "shape": "terminal", "label": "Cart" } },
|
|
32
|
+
{ "id": "address", "type": "shape", "data": { "shape": "io", "label": "Enter address & courier" } },
|
|
33
|
+
{ "id": "stock", "type": "shape", "data": { "shape": "decision", "label": "Enough stock?" } },
|
|
34
|
+
{ "id": "pay", "type": "shape", "data": { "shape": "process", "label": "Create invoice & pay" } },
|
|
35
|
+
{ "id": "out_of_stock", "type": "shape", "data": { "shape": "display", "label": "Show out of stock", "color": "#ef4444" } },
|
|
36
|
+
{ "id": "done", "type": "shape", "data": { "shape": "terminal", "label": "Order created", "color": "#10b981" } }
|
|
37
|
+
],
|
|
38
|
+
"edges": [
|
|
39
|
+
{ "id": "e1", "source": "start", "target": "address" },
|
|
40
|
+
{ "id": "e2", "source": "address", "target": "stock" },
|
|
41
|
+
{ "id": "e3", "source": "stock", "target": "pay", "label": "Yes" },
|
|
42
|
+
{ "id": "e4", "source": "stock", "target": "out_of_stock", "label": "No" },
|
|
43
|
+
{ "id": "e5", "source": "pay", "target": "done" }
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## PRD
|
|
49
|
+
|
|
50
|
+
The file `docs/prd-<feature>.md` has these sections:
|
|
51
|
+
- goals,
|
|
52
|
+
- users,
|
|
53
|
+
- flow (embed the flow),
|
|
54
|
+
- requirements (checklist),
|
|
55
|
+
- API (embed API contracts),
|
|
56
|
+
- data (embed ERD tables),
|
|
57
|
+
- acceptance criteria (table),
|
|
58
|
+
- out of scope.
|
|
59
|
+
|
|
60
|
+
````markdown
|
|
61
|
+
# PRD: Checkout
|
|
62
|
+
|
|
63
|
+
## Goals
|
|
64
|
+
|
|
65
|
+
Customers can complete a purchase from the cart on a single page.
|
|
66
|
+
|
|
67
|
+
## Flow
|
|
68
|
+
|
|
69
|
+
```embed
|
|
70
|
+
doc: flows/checkout.canvas.json
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Requirements
|
|
74
|
+
|
|
75
|
+
- [ ] Saved addresses can be selected again
|
|
76
|
+
- [ ] Stock is re-checked before the invoice is created
|
|
77
|
+
|
|
78
|
+
## Acceptance criteria
|
|
79
|
+
|
|
80
|
+
| Case | Result |
|
|
81
|
+
| --- | --- |
|
|
82
|
+
| Enough stock | Invoice created, customer redirected to payment |
|
|
83
|
+
| Out of stock | <span style="color:#ef4444">Out of stock</span> message, cart unchanged |
|
|
84
|
+
|
|
85
|
+
## Out of scope
|
|
86
|
+
|
|
87
|
+
- Vouchers and points
|
|
88
|
+
````
|
|
89
|
+
|
|
90
|
+
## Design system
|
|
91
|
+
|
|
92
|
+
The file `design-system.md` holds token tables and code blocks. Take the values from the code (CSS variables, Tailwind config, theme); don't make them up.
|
|
93
|
+
|
|
94
|
+
````markdown
|
|
95
|
+
# Design system
|
|
96
|
+
|
|
97
|
+
## Colors
|
|
98
|
+
|
|
99
|
+
| Token | Value | Usage |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| `primary` | `#7c3aed` | Primary buttons, links |
|
|
102
|
+
| `danger` | `#ef4444` | Errors, destructive actions |
|
|
103
|
+
|
|
104
|
+
## Typography
|
|
105
|
+
|
|
106
|
+
| Token | Size | Weight | Line height |
|
|
107
|
+
| --- | --- | --- | --- |
|
|
108
|
+
| `heading-1` | 32px | 700 | 1.2 |
|
|
109
|
+
| `body` | 15px | 400 | 1.6 |
|
|
110
|
+
|
|
111
|
+
## Spacing
|
|
112
|
+
|
|
113
|
+
```css
|
|
114
|
+
--space-1: 4px;
|
|
115
|
+
--space-2: 8px;
|
|
116
|
+
--space-4: 16px;
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Components
|
|
120
|
+
|
|
121
|
+
| Component | Variants | Notes |
|
|
122
|
+
| --- | --- | --- |
|
|
123
|
+
| Button | primary, secondary, danger | 36px tall, 8px radius |
|
|
124
|
+
````
|
|
125
|
+
|
|
126
|
+
## ERD from a schema
|
|
127
|
+
|
|
128
|
+
Read the schema (SQL migrations, Prisma, ORM models), then write `data/erd.canvas.json`:
|
|
129
|
+
- one `table` node per table, with id `tbl_<name>`,
|
|
130
|
+
- one edge per foreign key with `relation` and `sourceColumn`/`targetColumn` (`c_<column name>`); it points from the table holding the FK to the referenced table,
|
|
131
|
+
- use table names and types exactly as in the schema.
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"specsight": 1,
|
|
136
|
+
"name": "ERD",
|
|
137
|
+
"nodes": [
|
|
138
|
+
{ "id": "tbl_users", "type": "table", "data": { "name": "users", "columns": [
|
|
139
|
+
{ "name": "id", "type": "bigserial", "pk": true },
|
|
140
|
+
{ "name": "email", "type": "varchar(255)", "unique": true }
|
|
141
|
+
] } },
|
|
142
|
+
{ "id": "tbl_orders", "type": "table", "data": { "name": "orders", "columns": [
|
|
143
|
+
{ "name": "id", "type": "bigserial", "pk": true },
|
|
144
|
+
{ "name": "user_id", "type": "bigint", "fk": true },
|
|
145
|
+
{ "name": "total", "type": "numeric(12,2)" }
|
|
146
|
+
] } }
|
|
147
|
+
],
|
|
148
|
+
"edges": [
|
|
149
|
+
{ "id": "fk_orders_user", "source": "tbl_orders", "target": "tbl_users", "data": { "relation": "n-1", "sourceColumn": "c_user_id", "targetColumn": "c_id" } }
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## API contract from routes
|
|
155
|
+
|
|
156
|
+
Read the route definitions and their validation, then write `api/<module>.canvas.json`:
|
|
157
|
+
- one `api` node per endpoint, with id `api_<name>`,
|
|
158
|
+
- realistic example bodies that match the validation,
|
|
159
|
+
- responses for the success and error statuses the code actually returns.
|
|
160
|
+
|
|
161
|
+
Group endpoints per module with a `frame`, then embed each endpoint in the PRD.
|
|
162
|
+
|
|
163
|
+
## Sequence for integrations
|
|
164
|
+
|
|
165
|
+
Use a `sequence` node with a Mermaid `data.source` (see canvas-format.md) for flows like OAuth login, payment webhooks, or queue workers. One sequence per scenario. Use `alt`/`else` for error branches.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Specsight: siapkan, jalankan, dan periksa Specsight untuk satu project.
|
|
3
|
+
#
|
|
4
|
+
# specsight.sh ensure clone/update Specsight di ~/.specsight/app lalu install & build bila perlu
|
|
5
|
+
# specsight.sh start [root] jalankan server untuk <root>/.specsight (pakai yang sudah jalan bila ada); cetak URL
|
|
6
|
+
# specsight.sh check [root] periksa semua file di <root>/.specsight (JSON valid, embed, konten Doc)
|
|
7
|
+
# specsight.sh feedback [root] komentar terbuka + perubahan dari developer sejak terakhir dibaca
|
|
8
|
+
# specsight.sh stop [root] hentikan server project ini
|
|
9
|
+
#
|
|
10
|
+
# Env opsional: SPECSIGHT_REPO (URL/path repo, default GitHub), SPECSIGHT_REF (tag/branch, default versi skill ini),
|
|
11
|
+
# SPECSIGHT_HOME (default ~/.specsight)
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
|
|
14
|
+
# Versi app yang cocok dengan skill ini. Naikkan bersama tag baru saat rilis.
|
|
15
|
+
VERSION="v0.3.2"
|
|
16
|
+
REPO="${SPECSIGHT_REPO:-https://github.com/raisulkhairi/specsight.git}"
|
|
17
|
+
REF="${SPECSIGHT_REF:-$VERSION}"
|
|
18
|
+
HOME_DIR="${SPECSIGHT_HOME:-$HOME/.specsight}"
|
|
19
|
+
APP="$HOME_DIR/app"
|
|
20
|
+
|
|
21
|
+
die() { echo "specsight: $*" >&2; exit 1; }
|
|
22
|
+
need() { command -v "$1" >/dev/null 2>&1 || die "butuh '$1' — pasang dulu lalu ulangi"; }
|
|
23
|
+
|
|
24
|
+
build() {
|
|
25
|
+
echo "specsight: install & build di $APP …" >&2
|
|
26
|
+
(cd "$APP" && npm ci --no-audit --no-fund --loglevel=error && npm run build --silent) >&2
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
ensure() {
|
|
30
|
+
need git; need node; need npm
|
|
31
|
+
local major
|
|
32
|
+
major=$(node -p 'process.versions.node.split(".")[0]')
|
|
33
|
+
[ "$major" -ge 20 ] || die "butuh Node.js 20 atau lebih baru (sekarang $(node -v))"
|
|
34
|
+
mkdir -p "$HOME_DIR"
|
|
35
|
+
if [ ! -d "$APP/.git" ]; then
|
|
36
|
+
git clone --quiet --depth 1 --branch "$REF" "$REPO" "$APP" >&2 2>/dev/null \
|
|
37
|
+
|| die "tidak bisa mengambil Specsight $REF dari $REPO"
|
|
38
|
+
echo "$REF" >"$HOME_DIR/app-ref"
|
|
39
|
+
build
|
|
40
|
+
else
|
|
41
|
+
local before after
|
|
42
|
+
before=$(git -C "$APP" rev-parse HEAD)
|
|
43
|
+
# ambil persis versi $REF (tag atau branch); app tidak ikut berubah setiap ada push baru
|
|
44
|
+
if git -C "$APP" fetch --quiet --depth 1 "$REPO" "$REF" >&2 2>/dev/null; then
|
|
45
|
+
git -C "$APP" checkout --quiet --force FETCH_HEAD >&2
|
|
46
|
+
echo "$REF" >"$HOME_DIR/app-ref"
|
|
47
|
+
else
|
|
48
|
+
echo "specsight: gagal mengambil $REF, memakai versi yang sudah ada" >&2
|
|
49
|
+
fi
|
|
50
|
+
after=$(git -C "$APP" rev-parse HEAD)
|
|
51
|
+
if [ "$before" != "$after" ] || [ ! -d "$APP/dist" ] || [ ! -d "$APP/node_modules" ]; then build; fi
|
|
52
|
+
fi
|
|
53
|
+
echo "Specsight siap: $APP ($(cat "$HOME_DIR/app-ref" 2>/dev/null || echo '?'), $(git -C "$APP" rev-parse --short HEAD))"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
project_dir() {
|
|
57
|
+
local root
|
|
58
|
+
root=$(cd "${1:-.}" && pwd)
|
|
59
|
+
# project dari versi lama (nama Specloop / Syntext): pindahkan foldernya ke .specsight/ sekali
|
|
60
|
+
local old
|
|
61
|
+
for old in .specloop .syntext; do
|
|
62
|
+
if [ -d "$root/$old" ] && [ ! -e "$root/.specsight" ]; then
|
|
63
|
+
mv "$root/$old" "$root/.specsight"
|
|
64
|
+
echo "specsight: folder $old/ dipindah ke .specsight/ (nama baru); commit perubahan ini di git" >&2
|
|
65
|
+
fi
|
|
66
|
+
done
|
|
67
|
+
echo "$root/.specsight"
|
|
68
|
+
}
|
|
69
|
+
dir_hash() { node -p 'require("crypto").createHash("sha1").update(process.argv[1]).digest("hex").slice(0, 10)' "$1"; }
|
|
70
|
+
|
|
71
|
+
# port server yang sedang melayani folder ini, atau kosong
|
|
72
|
+
running_port() {
|
|
73
|
+
local dir="$1" rt="$1/.runtime.json"
|
|
74
|
+
[ -f "$rt" ] || return 0
|
|
75
|
+
node -e '
|
|
76
|
+
const [rt, dir] = process.argv.slice(1)
|
|
77
|
+
const { port } = JSON.parse(require("fs").readFileSync(rt, "utf8"))
|
|
78
|
+
fetch(`http://127.0.0.1:${port}/api/info`).then((r) => r.json())
|
|
79
|
+
.then((i) => { if (i.dir === dir) console.log(port) }).catch(() => {})
|
|
80
|
+
' "$rt" "$dir"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
start() {
|
|
84
|
+
[ -d "$APP/dist" ] || ensure >/dev/null
|
|
85
|
+
local dir port log
|
|
86
|
+
dir=$(project_dir "${1:-.}")
|
|
87
|
+
port=$(running_port "$dir")
|
|
88
|
+
if [ -n "$port" ]; then echo "http://localhost:$port"; return; fi
|
|
89
|
+
mkdir -p "$dir" "$HOME_DIR/logs"
|
|
90
|
+
rm -f "$dir/.runtime.json"
|
|
91
|
+
local id want
|
|
92
|
+
id=$(dir_hash "$dir")
|
|
93
|
+
log="$HOME_DIR/logs/$id.log"
|
|
94
|
+
# port terakhir project ini dipakai lagi, supaya link yang sudah dibagikan tetap jalan setelah restart
|
|
95
|
+
mkdir -p "$HOME_DIR/ports"
|
|
96
|
+
want=$(cat "$HOME_DIR/ports/$id" 2>/dev/null || echo 8787)
|
|
97
|
+
nohup npm --prefix "$APP" start --silent -- --dir "$dir" --port "$want" >"$log" 2>&1 &
|
|
98
|
+
disown || true
|
|
99
|
+
for _ in $(seq 1 60); do
|
|
100
|
+
port=$(running_port "$dir")
|
|
101
|
+
if [ -n "$port" ]; then
|
|
102
|
+
if [ "$port" != "$want" ] && [ -f "$HOME_DIR/ports/$id" ]; then
|
|
103
|
+
echo "specsight: port $want sedang dipakai, sekarang memakai $port (link lama dengan port $want tidak berlaku)" >&2
|
|
104
|
+
fi
|
|
105
|
+
echo "$port" >"$HOME_DIR/ports/$id"
|
|
106
|
+
echo "http://localhost:$port"; return
|
|
107
|
+
fi
|
|
108
|
+
sleep 0.25
|
|
109
|
+
done
|
|
110
|
+
die "server tidak menyala dalam 15 detik — lihat log: $log"
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
check() {
|
|
114
|
+
[ -d "$APP/node_modules" ] || ensure >/dev/null
|
|
115
|
+
npm --prefix "$APP" run --silent check -- --dir "$(project_dir "${1:-.}")"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
feedback() {
|
|
119
|
+
[ -d "$APP/node_modules" ] || ensure >/dev/null
|
|
120
|
+
npm --prefix "$APP" run --silent feedback -- --dir "$(project_dir "${1:-.}")"
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
stop() {
|
|
124
|
+
local rt
|
|
125
|
+
rt="$(project_dir "${1:-.}")/.runtime.json"
|
|
126
|
+
[ -f "$rt" ] || { echo "specsight: tidak ada server yang berjalan untuk project ini"; return; }
|
|
127
|
+
kill "$(node -p 'JSON.parse(require("fs").readFileSync(process.argv[1], "utf8")).pid' "$rt")" 2>/dev/null || true
|
|
128
|
+
echo "specsight: server dihentikan"
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
case "${1:-}" in
|
|
132
|
+
ensure) ensure ;;
|
|
133
|
+
start) start "${2:-.}" ;;
|
|
134
|
+
check) check "${2:-.}" ;;
|
|
135
|
+
feedback) feedback "${2:-.}" ;;
|
|
136
|
+
stop) stop "${2:-.}" ;;
|
|
137
|
+
*) die "pemakaian: specsight.sh ensure | start [root] | check [root] | feedback [root] | stop [root]" ;;
|
|
138
|
+
esac
|