srcpack 0.3.0 → 1.0.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/README.md CHANGED
@@ -10,7 +10,7 @@ Zero-config CLI for bundling code into LLM-optimized context files.
10
10
 
11
11
  ```bash
12
12
  npx srcpack init # Create config interactively
13
- npx srcpack # Bundle all
13
+ npx srcpack # Bundle all except on-demand
14
14
  ```
15
15
 
16
16
  ## Why
@@ -57,7 +57,7 @@ Or add to `package.json`:
57
57
  | `bundles` | — | Named bundle definitions |
58
58
  | `upload` | — | Upload destination(s) |
59
59
 
60
- \*Only the default `.srcpack` is emptied automatically — it's srcpack's directory by convention. Any other `outDir` needs an explicit `emptyOutDir: true`, so `outDir: "src"` can't quietly delete your sources. Emptying also happens only on a full run, so `npx srcpack web` leaves other bundles in place.
60
+ \*Only the default `.srcpack` is emptied automatically — it's srcpack's directory by convention. Any other `outDir` needs an explicit `emptyOutDir: true`, so `outDir: "src"` can't quietly delete your sources. Named runs (`npx srcpack web`) never empty it, so other bundles stay in place.
61
61
 
62
62
  ### Bundle Config
63
63
 
@@ -78,9 +78,11 @@ Or add to `package.json`:
78
78
  {
79
79
  include: "src/**/*",
80
80
  linear: { team: "ENG" }, // Linear issues as virtual files
81
+ screenshot: "http://localhost:5173", // rendered page as numbered PNGs
81
82
  outfile: "~/Downloads/bundle.txt", // custom output path
82
83
  index: true, // include index header (default)
83
- prompt: "./prompts/review.md" // prepend from file (or inline text)
84
+ prompt: "./prompts/review.md", // prepend from file (or inline text)
85
+ onDemand: true // build only when named
84
86
  }
85
87
  ```
86
88
 
@@ -88,6 +90,8 @@ Patterns follow glob syntax. Prefix with `!` to exclude, `+` to force-include (b
88
90
 
89
91
  A pattern can also name a set of changed files: `git:staged`, `git:unstaged`, `git:untracked`, `git:dirty`, or `git:<rev>` (e.g. `git:main`, `git:HEAD~3`). Deleted files are skipped, and `git:<rev>` compares against the merge base so a stale branch still reports only your own changes. See [Git sources](https://kriasoft.com/srcpack/configuration#git-sources-git-prefix).
90
92
 
93
+ A full run skips bundles marked `onDemand: true`; name them explicitly to build them. Emptying `outDir` still removes their previous output there. See [On-Demand Bundles](https://kriasoft.com/srcpack/configuration#on-demand-bundles).
94
+
91
95
  ### Linear Issues
92
96
 
93
97
  A bundle can include [Linear](https://linear.app) issues next to your code. Each issue becomes a virtual file at `linear/issues/ENG-123.md`, so it gets its own index entry and line range — letting you ask whether `[4] src/board.ts` actually implements `[2] ENG-123`.
@@ -104,6 +108,18 @@ bundles: {
104
108
 
105
109
  Authentication reads `LINEAR_API_KEY` from the environment (Linear → Settings → Security & access → Personal API keys), never from the config file. `team` is required, completed/canceled/duplicate issues are excluded by default, and issues obey `!` exclusions like any other entry. See [Linear issues](https://kriasoft.com/srcpack/configuration#linear-issues).
106
110
 
111
+ ### Screenshots
112
+
113
+ A bundle can capture a rendered page as PNGs, with overlapping detail slices for tall pages. Srcpack scrolls to load lazy content before capture and hides Astro and Nuxt dev toolbars.
114
+
115
+ ```typescript
116
+ bundles: {
117
+ home: { screenshot: "http://localhost:5173/", onDemand: true },
118
+ }
119
+ ```
120
+
121
+ `npx srcpack home` writes PNGs to `.srcpack`: `home-00.png` is the whole page when available; tall pages also get `home-01.png`, `home-02.png`, … detail slices. Attach them in filename order. Images stay local, even with upload configured. For a one-off, no config is needed: `npx srcpack --screenshot localhost:5173 --viewport mobile`. See [Screenshots](https://kriasoft.com/srcpack/configuration#screenshots) for Playwright and browser setup.
122
+
107
123
  ### Google Drive Upload
108
124
 
109
125
  To upload bundles to Google Drive, add OAuth credentials to your config:
@@ -154,14 +170,15 @@ import { utils } from "./utils";
154
170
  ## CLI
155
171
 
156
172
  ```bash
157
- npx srcpack # Bundle all, upload if configured
173
+ npx srcpack # Bundle all except on-demand, upload if configured
158
174
  npx srcpack web api # Bundle specific bundles only
159
175
  npx srcpack --staged # Bundle staged changes (no config needed)
160
176
  npx srcpack --dirty # Bundle staged + unstaged + untracked
161
177
  npx srcpack --since main # Bundle changes since main
178
+ npx srcpack --screenshot localhost:5173 # Capture a page as PNGs
162
179
  npx srcpack --dry-run # Preview without writing files
163
180
  npx srcpack --emptyOutDir # Empty output directory before writing
164
- npx srcpack --no-emptyOutDir # Keep existing files in output directory
181
+ npx srcpack --no-emptyOutDir # Skip clearing the output directory
165
182
  npx srcpack --no-upload # Bundle only, skip upload
166
183
  npx srcpack init # Interactive config setup
167
184
  npx srcpack login # Authenticate with Google Drive
package/dist/args.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import type { BundleConfig } from "./config.ts";
2
+ /** A mistake on the command line: reported without a stack trace. */
3
+ export declare class UsageError extends Error {
4
+ constructor(message: string);
5
+ }
6
+ /**
7
+ * One-off bundle from a `git:` source or a URL; no config file required.
8
+ */
9
+ export interface AdHocBundle {
10
+ name: string;
11
+ source: BundleConfig;
12
+ }
13
+ export interface CliArgs {
14
+ /** Bundle names in input order. Empty for full and ad-hoc runs. */
15
+ bundles: string[];
16
+ adHoc: AdHocBundle | null;
17
+ dryRun: boolean;
18
+ /** Explicit CLI override; `undefined` lets the CLI apply config and run defaults. */
19
+ emptyOutDir: boolean | undefined;
20
+ upload: boolean;
21
+ }
22
+ /**
23
+ * Parse everything after `srcpack` except `--help`, `--version` and the
24
+ * `init`/`login` subcommands, which the CLI handles before this.
25
+ */
26
+ export declare function parseCliArgs(argv: string[]): CliArgs;
package/dist/bundle.d.ts CHANGED
@@ -21,27 +21,6 @@ export interface BundleResult {
21
21
  content: string;
22
22
  index: IndexEntry[];
23
23
  }
24
- /**
25
- * The key two paths are compared by: canonical spelling, then case folded, on
26
- * every platform. A case-insensitive filesystem — the default on macOS and
27
- * Windows — treats `Context.txt` and `context.txt` as one directory entry, and
28
- * APFS additionally folds Unicode normalisation, so `Café.txt` written as
29
- * precomposed U+00E9 and as `e` plus U+0301 is also one entry. Normalising
30
- * before folding is what makes the comparison sound: equal inputs stay equal
31
- * afterwards whether or not case folding preserves normalisation. `realpath`
32
- * resolves
33
- * an existing component to its on-disk spelling, but that doesn't cover these:
34
- * an output not yet written has no on-disk spelling, and the destination entry
35
- * is deliberately left unresolved so `rename` replaces a symlink rather than
36
- * following it. A config that works in Linux CI and loses a bundle on the
37
- * author's laptop is worse than one rejected everywhere, so the rule is the
38
- * same on every platform rather than keyed to the filesystem under it.
39
- *
40
- * Comparison only. Paths used for I/O keep their original spelling, and
41
- * ownership stays an exact match: folding there could only widen what srcpack
42
- * deletes, which is the one direction that must never be widened by a guess.
43
- */
44
- export declare function pathKey(path: string): string;
45
24
  /**
46
25
  * Resolve bundle config to a list of file paths.
47
26
  * - Regular patterns respect .gitignore