@captainsafia/stitch 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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +263 -0
  3. package/package.json +52 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Safia Abdalla
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 ADDED
@@ -0,0 +1,263 @@
1
+ # :thread: stitch: the intent log for agents and humans
2
+
3
+ Stitch is a tool to help agents (and humans!) record their **intent** ("stitches") and bind it to **git commits/diffs**, forming an **intent DAG** that can't be represented by git's linear history or the textual representation of a diff.
4
+
5
+ Stitch helps you capture the "why" behind your code changes, creating a semantic layer on top of git that connects you and your agents' intentions to your implementations.
6
+
7
+ ## Features
8
+
9
+ - **Intent Tracking**: Create and manage "stitches" - documents that capture the intent behind code changes
10
+ - **Git Integration**: Link stitches to commits, commit ranges, and staged diffs
11
+ - **DAG Relationships**: Build hierarchical relationships with parent/child stitches and dependencies
12
+ - **Stitch Blame**: See which intent is behind each line of code
13
+
14
+ ## Installation
15
+
16
+ ### Binary (Recommended)
17
+
18
+ ```bash
19
+ curl -fsSL https://raw.githubusercontent.com/captainsafia/stitch/main/scripts/install.sh | bash
20
+ ```
21
+
22
+ ### Building from Source
23
+
24
+ ```bash
25
+ git clone https://github.com/captainsafia/stitch.git
26
+ cd stitch
27
+ bun install
28
+ bun run compile
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```bash
34
+ # Initialize stitch in your repository
35
+ stitch init
36
+
37
+ # Start a new stitch session
38
+ stitch start "Implement user authentication"
39
+
40
+ # Work on your code, then link commits
41
+ git add .
42
+ git commit -m "Add login form"
43
+ stitch link --commit HEAD
44
+
45
+ # Create a child stitch for sub-tasks
46
+ stitch child "Add password validation"
47
+
48
+ # See stitch attribution for any file
49
+ stitch blame src/auth.ts
50
+ ```
51
+
52
+ ## Commands
53
+
54
+ ### Session Management
55
+
56
+ #### `stitch init`
57
+
58
+ Initialize stitch in the current git repository. Creates the `.stitch/` directory structure.
59
+
60
+ #### `stitch start <title>`
61
+
62
+ Start a new stitch session with the given title. Sets this as the current stitch.
63
+
64
+ ```bash
65
+ stitch start Implement user authentication
66
+ ```
67
+
68
+ #### `stitch child <title>`
69
+
70
+ Create a child stitch under the current stitch. Useful for breaking down larger tasks.
71
+
72
+ ```bash
73
+ stitch child "Add password validation"
74
+ ```
75
+
76
+ #### `stitch switch <id>`
77
+
78
+ Switch to a different stitch by ID.
79
+
80
+ ```bash
81
+ stitch switch S-20251228-3f2a
82
+ ```
83
+
84
+ #### `stitch status`
85
+
86
+ Show the current stitch and its lineage (ancestor chain).
87
+
88
+ ### Viewing Stitches
89
+
90
+ #### `stitch list [--status <status>]`
91
+
92
+ List all stitches, optionally filtered by status.
93
+
94
+ ```bash
95
+ stitch list
96
+ stitch list --status open
97
+ stitch list --status closed
98
+ ```
99
+
100
+ **Status options:** `open`, `closed`, `superseded`, `abandoned`
101
+
102
+ #### `stitch show <id>`
103
+
104
+ Show details of a specific stitch.
105
+
106
+ ```bash
107
+ stitch show S-20251228-3f2a
108
+ ```
109
+
110
+ #### `stitch edit [id]`
111
+
112
+ Open a stitch in your editor. Defaults to the current stitch.
113
+
114
+ ```bash
115
+ stitch edit
116
+ stitch edit S-20251228-3f2a
117
+ ```
118
+
119
+ ### Linking to Git
120
+
121
+ #### `stitch link --commit <sha>`
122
+
123
+ Link a specific commit to the current stitch (or specify `--id`).
124
+
125
+ ```bash
126
+ stitch link --commit HEAD
127
+ stitch link --commit abc1234
128
+ stitch link --commit HEAD --id S-20251228-3f2a
129
+ ```
130
+
131
+ #### `stitch link --range <range>`
132
+
133
+ Link a commit range to the current stitch.
134
+
135
+ ```bash
136
+ stitch link --range origin/main..HEAD
137
+ ```
138
+
139
+ #### `stitch link --staged`
140
+
141
+ Create a fingerprint of the current staged diff and link it to the current stitch.
142
+
143
+ ```bash
144
+ stitch link --staged
145
+ ```
146
+
147
+ ### Blame
148
+
149
+ #### `stitch blame <path> [--format plain|json]`
150
+
151
+ Show stitch attribution for each line in a file.
152
+
153
+ ```bash
154
+ stitch blame src/auth.ts
155
+ stitch blame src/auth.ts --format json
156
+ ```
157
+
158
+ ## Stitch File Format
159
+
160
+ Stitches are stored as Markdown files with TOML frontmatter in `.stitch/stitches/`:
161
+
162
+ ```markdown
163
+ +++
164
+ id = "S-20251228-3f2a"
165
+ title = "Implement user authentication"
166
+ status = "open"
167
+ created_at = "2025-12-28T22:41:00-08:00"
168
+ updated_at = "2025-12-28T22:41:00-08:00"
169
+ provenance = "human"
170
+ confidence = "medium"
171
+ tags = ["auth", "security"]
172
+
173
+ [relations]
174
+ parent = "S-20251228-aaaa"
175
+
176
+ [git]
177
+ links = [
178
+ { kind = "commit", sha = "deadbeef..." },
179
+ ]
180
+ +++
181
+
182
+ ## Intent
183
+
184
+ Implement secure user authentication with session management.
185
+
186
+ ## Constraints
187
+
188
+ - Must use bcrypt for password hashing
189
+ - Sessions expire after 24 hours
190
+
191
+ ## Notes
192
+
193
+ Consider adding OAuth support in a future iteration.
194
+ ```
195
+
196
+ ## Library Usage
197
+
198
+ Stitch can also be used as a TypeScript library:
199
+
200
+ ```typescript
201
+ import { StitchClient } from 'stitch';
202
+
203
+ const client = new StitchClient();
204
+
205
+ // Initialize and create stitches
206
+ await client.init();
207
+ const stitch = await client.start("My feature");
208
+
209
+ // Link commits
210
+ await client.linkCommit("abc1234");
211
+
212
+ // Get blame information
213
+ const blame = await client.blame("src/file.ts");
214
+ for (const line of blame) {
215
+ console.log(`Line ${line.line}: ${line.stitchIds.join(", ") || "unstitched"}`);
216
+ }
217
+
218
+ client.close();
219
+ ```
220
+
221
+ ## Configuration
222
+
223
+ Stitch stores all data in your repository under `.stitch/`:
224
+
225
+ ```
226
+ .stitch/
227
+ ├── current # Current stitch ID
228
+ └── stitches/ # Stitch documents
229
+ └── S-YYYYMMDD-xxxx.md
230
+ ```
231
+
232
+ **Environment Variables:**
233
+
234
+ - `EDITOR` or `VISUAL` - Editor for `stitch edit` command
235
+ - `DEBUG=1` - Enable debug output with stack traces
236
+
237
+ ## Development
238
+
239
+ ### Setup
240
+
241
+ ```bash
242
+ git clone https://github.com/captainsafia/stitch.git
243
+ cd stitch
244
+ bun install
245
+ ```
246
+
247
+ ### Testing
248
+
249
+ ```bash
250
+ bun test # Run all tests
251
+ bun run typecheck # Type checking
252
+ ```
253
+
254
+ ### Building
255
+
256
+ ```bash
257
+ bun run build # Build for npm distribution
258
+ bun run compile # Compile standalone binary
259
+ ```
260
+
261
+ ## Contributing
262
+
263
+ Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@captainsafia/stitch",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "description": "A local-first CLI for recording intent and binding it to git commits/diffs",
6
+ "main": "dist/api.js",
7
+ "types": "dist/api.d.ts",
8
+ "bin": {
9
+ "stitch": "dist/cli.js"
10
+ },
11
+ "files": [
12
+ "dist"
13
+ ],
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/api.d.ts",
17
+ "import": "./dist/api.js"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "build": "bun build src/api.ts --outdir dist --target node && dts-bundle-generator -o dist/api.d.ts src/api.ts",
22
+ "compile": "bun build src/cli.ts --compile --outfile stitch",
23
+ "compile:linux-x64": "bun build src/cli.ts --compile --target=bun-linux-x64 --outfile stitch-linux-x64",
24
+ "compile:linux-arm64": "bun build src/cli.ts --compile --target=bun-linux-arm64 --outfile stitch-linux-arm64",
25
+ "compile:darwin-x64": "bun build src/cli.ts --compile --target=bun-darwin-x64 --outfile stitch-darwin-x64",
26
+ "compile:darwin-arm64": "bun build src/cli.ts --compile --target=bun-darwin-arm64 --outfile stitch-darwin-arm64",
27
+ "compile:windows-x64": "bun build src/cli.ts --compile --target=bun-windows-x64 --outfile stitch-windows-x64.exe",
28
+ "test": "bun test",
29
+ "typecheck": "tsc --noEmit"
30
+ },
31
+ "devDependencies": {
32
+ "@types/bun": "latest",
33
+ "dts-bundle-generator": "^9.5.1",
34
+ "typescript": "^5"
35
+ },
36
+ "dependencies": {
37
+ "commander": "^12.0.0",
38
+ "smol-toml": "^1.3.0"
39
+ },
40
+ "license": "MIT",
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "https://github.com/captainsafia/stitch.git"
44
+ },
45
+ "keywords": [
46
+ "git",
47
+ "intent",
48
+ "dag",
49
+ "cli",
50
+ "developer-tools"
51
+ ]
52
+ }