@stigmer/plugin-package 3.16.0 → 3.17.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.
Files changed (86) hide show
  1. package/client/archive.d.ts +27 -0
  2. package/client/archive.d.ts.map +1 -0
  3. package/client/archive.js +38 -0
  4. package/client/archive.js.map +1 -0
  5. package/client/ignore/defaults.d.ts +2 -0
  6. package/client/ignore/defaults.d.ts.map +1 -0
  7. package/client/ignore/defaults.js +140 -0
  8. package/client/ignore/defaults.js.map +1 -0
  9. package/client/ignore/match.d.ts +3 -0
  10. package/client/ignore/match.d.ts.map +1 -0
  11. package/client/ignore/match.js +166 -0
  12. package/client/ignore/match.js.map +1 -0
  13. package/client/ignore/matcher.d.ts +50 -0
  14. package/client/ignore/matcher.d.ts.map +1 -0
  15. package/client/ignore/matcher.js +116 -0
  16. package/client/ignore/matcher.js.map +1 -0
  17. package/client/ignore/pattern.d.ts +13 -0
  18. package/client/ignore/pattern.d.ts.map +1 -0
  19. package/client/ignore/pattern.js +118 -0
  20. package/client/ignore/pattern.js.map +1 -0
  21. package/client/refs.d.ts +76 -0
  22. package/client/refs.d.ts.map +1 -0
  23. package/client/refs.js +123 -0
  24. package/client/refs.js.map +1 -0
  25. package/client/select.d.ts +74 -0
  26. package/client/select.d.ts.map +1 -0
  27. package/client/select.js +121 -0
  28. package/client/select.js.map +1 -0
  29. package/client/vocabulary.d.ts +13 -0
  30. package/client/vocabulary.d.ts.map +1 -0
  31. package/client/vocabulary.js +17 -0
  32. package/client/vocabulary.js.map +1 -0
  33. package/client.d.ts +34 -0
  34. package/client.d.ts.map +1 -0
  35. package/client.js +34 -0
  36. package/client.js.map +1 -0
  37. package/files.d.ts +6 -0
  38. package/files.d.ts.map +1 -1
  39. package/files.js +6 -0
  40. package/files.js.map +1 -1
  41. package/index.d.ts +11 -6
  42. package/index.d.ts.map +1 -1
  43. package/index.js +9 -5
  44. package/index.js.map +1 -1
  45. package/marketplace/messages.d.ts +20 -0
  46. package/marketplace/messages.d.ts.map +1 -0
  47. package/marketplace/messages.js +50 -0
  48. package/marketplace/messages.js.map +1 -0
  49. package/marketplace/outcome.d.ts +72 -0
  50. package/marketplace/outcome.d.ts.map +1 -0
  51. package/marketplace/outcome.js +29 -0
  52. package/marketplace/outcome.js.map +1 -0
  53. package/marketplace/read-marketplace.d.ts +34 -0
  54. package/marketplace/read-marketplace.d.ts.map +1 -0
  55. package/marketplace/read-marketplace.js +359 -0
  56. package/marketplace/read-marketplace.js.map +1 -0
  57. package/messages.d.ts +25 -9
  58. package/messages.d.ts.map +1 -1
  59. package/messages.js +24 -8
  60. package/messages.js.map +1 -1
  61. package/outcome.d.ts +13 -6
  62. package/outcome.d.ts.map +1 -1
  63. package/package.json +8 -2
  64. package/src/__test-utils__/read.ts +4 -4
  65. package/src/__tests__/client-ignore.test.ts +133 -0
  66. package/src/__tests__/client-refs.test.ts +101 -0
  67. package/src/__tests__/client-select-archive.test.ts +152 -0
  68. package/src/__tests__/fixtures/cursor-plugins/.cursor-plugin/marketplace.json +412 -0
  69. package/src/__tests__/fixtures/cursor-plugins/NOTICE +5 -0
  70. package/src/__tests__/marketplace.test.ts +373 -0
  71. package/src/client/archive.ts +44 -0
  72. package/src/client/ignore/defaults.ts +155 -0
  73. package/src/client/ignore/match.ts +158 -0
  74. package/src/client/ignore/matcher.ts +156 -0
  75. package/src/client/ignore/pattern.ts +131 -0
  76. package/src/client/refs.ts +170 -0
  77. package/src/client/select.ts +161 -0
  78. package/src/client/vocabulary.ts +19 -0
  79. package/src/client.ts +67 -0
  80. package/src/files.ts +6 -0
  81. package/src/index.ts +21 -5
  82. package/src/marketplace/messages.ts +62 -0
  83. package/src/marketplace/outcome.ts +95 -0
  84. package/src/marketplace/read-marketplace.ts +402 -0
  85. package/src/messages.ts +34 -21
  86. package/src/outcome.ts +14 -6
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The archive a plugin push sends, and its digest.
3
+ *
4
+ * The server's identity for a plugin version is the SHA-256 of the bytes it
5
+ * receives, so a client that can compute those bytes knows "already
6
+ * installed" and "upgrade available" without pushing. That is only true if
7
+ * every client builds the archive the same way: the selected files in
8
+ * selection order, one DOS-epoch mtime on every entry, one compression
9
+ * level. These are the CLI's original options (the skill packager's
10
+ * discipline, kept byte for byte); changing any of them would make every
11
+ * installed plugin look like an upgrade.
12
+ *
13
+ * The digest is WebCrypto's, which Node 22 and every browser provide, so
14
+ * there is one hash implementation and it is asynchronous everywhere.
15
+ */
16
+ import type { PluginFiles } from "../files.js";
17
+ /**
18
+ * The one mtime every entry carries: the DOS epoch, at local midnight so
19
+ * the DOS time field reads 00:00 in every zone. Construct it locally rather
20
+ * than from UTC: fflate converts through the Date's local getters.
21
+ */
22
+ export declare const DETERMINISTIC_ZIP_MTIME: Date;
23
+ /** Zip the selected files in their listed order. */
24
+ export declare function archivePlugin(files: PluginFiles): Uint8Array;
25
+ /** Lowercase hex SHA-256 of `bytes`: the server's `status.digest` for these bytes. */
26
+ export declare function digestArchive(bytes: Uint8Array): Promise<string>;
27
+ //# sourceMappingURL=archive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.d.ts","sourceRoot":"","sources":["../../src/client/archive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,MAAuB,CAAC;AAK5D,oDAAoD;AACpD,wBAAgB,aAAa,CAAC,KAAK,EAAE,WAAW,GAAG,UAAU,CAM5D;AAED,sFAAsF;AACtF,wBAAsB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAGtE"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The archive a plugin push sends, and its digest.
3
+ *
4
+ * The server's identity for a plugin version is the SHA-256 of the bytes it
5
+ * receives, so a client that can compute those bytes knows "already
6
+ * installed" and "upgrade available" without pushing. That is only true if
7
+ * every client builds the archive the same way: the selected files in
8
+ * selection order, one DOS-epoch mtime on every entry, one compression
9
+ * level. These are the CLI's original options (the skill packager's
10
+ * discipline, kept byte for byte); changing any of them would make every
11
+ * installed plugin look like an upgrade.
12
+ *
13
+ * The digest is WebCrypto's, which Node 22 and every browser provide, so
14
+ * there is one hash implementation and it is asynchronous everywhere.
15
+ */
16
+ import { zipSync } from "fflate";
17
+ /**
18
+ * The one mtime every entry carries: the DOS epoch, at local midnight so
19
+ * the DOS time field reads 00:00 in every zone. Construct it locally rather
20
+ * than from UTC: fflate converts through the Date's local getters.
21
+ */
22
+ export const DETERMINISTIC_ZIP_MTIME = new Date(1980, 0, 1);
23
+ /** The deflate level the skill packager chose; part of the identity. */
24
+ const ARCHIVE_LEVEL = 6;
25
+ /** Zip the selected files in their listed order. */
26
+ export function archivePlugin(files) {
27
+ const tree = {};
28
+ for (const entry of files.entries) {
29
+ tree[entry.path] = files.read(entry.path);
30
+ }
31
+ return zipSync(tree, { level: ARCHIVE_LEVEL, mtime: DETERMINISTIC_ZIP_MTIME });
32
+ }
33
+ /** Lowercase hex SHA-256 of `bytes`: the server's `status.digest` for these bytes. */
34
+ export async function digestArchive(bytes) {
35
+ const hash = await globalThis.crypto.subtle.digest("SHA-256", bytes);
36
+ return Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join("");
37
+ }
38
+ //# sourceMappingURL=archive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"archive.js","sourceRoot":"","sources":["../../src/client/archive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAIjC;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAE5D,wEAAwE;AACxE,MAAM,aAAa,GAAG,CAAC,CAAC;AAExB,oDAAoD;AACpD,MAAM,UAAU,aAAa,CAAC,KAAkB;IAC9C,MAAM,IAAI,GAA+B,EAAE,CAAC;IAC5C,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAAC;AACjF,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,KAAiB;IACnD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACrE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACjG,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const DEFAULT_PATTERNS: readonly string[];
2
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/client/ignore/defaults.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAsJ7C,CAAC"}
@@ -0,0 +1,140 @@
1
+ // Built-in security-first ignore patterns, applied (lowest priority) unless
2
+ // disabled. A verbatim port of the Go CLI's DefaultPatterns so `push` excludes
3
+ // the same secrets, VCS metadata, and build artifacts on both CLIs.
4
+ export const DEFAULT_PATTERNS = [
5
+ // Version control
6
+ ".git/",
7
+ ".svn/",
8
+ ".hg/",
9
+ ".bzr/",
10
+ // Environment files (often contain secrets)
11
+ ".env",
12
+ ".env.*",
13
+ "!.env.example",
14
+ "!.env.template",
15
+ "!.env.sample",
16
+ // Private keys and certificates
17
+ "*.pem",
18
+ "*.key",
19
+ "*.p12",
20
+ "*.pfx",
21
+ "*.keystore",
22
+ "*.jks",
23
+ "id_rsa",
24
+ "id_rsa.*",
25
+ "id_ed25519",
26
+ "id_ed25519.*",
27
+ "id_dsa",
28
+ "id_dsa.*",
29
+ // Cloud credentials
30
+ "credentials.json",
31
+ "service-account*.json",
32
+ "gcp-credentials*.json",
33
+ "aws-credentials",
34
+ ".aws/credentials",
35
+ ".aws/config",
36
+ // Generic secrets
37
+ ".secrets",
38
+ ".secrets/",
39
+ "*.secret",
40
+ ".credentials/",
41
+ "secrets.yaml",
42
+ "secrets.yml",
43
+ "secrets.json",
44
+ // Package manager auth
45
+ ".npmrc",
46
+ ".pypirc",
47
+ ".gem/credentials",
48
+ ".docker/config.json",
49
+ // IDE and editor
50
+ ".idea/",
51
+ ".vscode/",
52
+ "*.swp",
53
+ "*.swo",
54
+ "*.swn",
55
+ "*~",
56
+ ".project",
57
+ ".classpath",
58
+ ".settings/",
59
+ "*.sublime-workspace",
60
+ "*.sublime-project",
61
+ ".vs/",
62
+ // Operating system
63
+ ".DS_Store",
64
+ ".DS_Store?",
65
+ "._*",
66
+ ".Spotlight-V100",
67
+ ".Trashes",
68
+ "Thumbs.db",
69
+ "Thumbs.db:encryptable",
70
+ "desktop.ini",
71
+ "ehthumbs.db",
72
+ "ehthumbs_vista.db",
73
+ // Node.js
74
+ "node_modules/",
75
+ "npm-debug.log*",
76
+ "yarn-debug.log*",
77
+ "yarn-error.log*",
78
+ ".npm/",
79
+ ".yarn/cache/",
80
+ ".yarn/unplugged/",
81
+ ".pnp.*",
82
+ // Python
83
+ "__pycache__/",
84
+ "*.py[cod]",
85
+ "*$py.class",
86
+ ".Python",
87
+ "*.so",
88
+ ".venv/",
89
+ "venv/",
90
+ "env/",
91
+ "ENV/",
92
+ ".pytest_cache/",
93
+ ".mypy_cache/",
94
+ ".ruff_cache/",
95
+ ".tox/",
96
+ ".nox/",
97
+ "*.egg-info/",
98
+ ".eggs/",
99
+ "dist/",
100
+ "build/",
101
+ "develop-eggs/",
102
+ ".installed.cfg",
103
+ "*.manifest",
104
+ "*.spec",
105
+ "pip-log.txt",
106
+ "pip-delete-this-directory.txt",
107
+ // Java/JVM
108
+ "target/",
109
+ "*.class",
110
+ "*.jar",
111
+ "*.war",
112
+ "*.ear",
113
+ ".gradle/",
114
+ "gradle-app.setting",
115
+ ".gradletasknamecache",
116
+ // Go
117
+ "vendor/",
118
+ // Rust
119
+ "target/",
120
+ "Cargo.lock",
121
+ // Coverage and test reports
122
+ "coverage/",
123
+ ".coverage",
124
+ "htmlcov/",
125
+ ".nyc_output/",
126
+ "coverage.xml",
127
+ "*.cover",
128
+ ".hypothesis/",
129
+ // Logs
130
+ "*.log",
131
+ "logs/",
132
+ // Temporary files
133
+ "tmp/",
134
+ "temp/",
135
+ "*.tmp",
136
+ "*.temp",
137
+ "*.bak",
138
+ "*.backup",
139
+ ];
140
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../../src/client/ignore/defaults.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,+EAA+E;AAC/E,oEAAoE;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,kBAAkB;IAClB,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IAEP,4CAA4C;IAC5C,MAAM;IACN,QAAQ;IACR,eAAe;IACf,gBAAgB;IAChB,cAAc;IAEd,gCAAgC;IAChC,OAAO;IACP,OAAO;IACP,OAAO;IACP,OAAO;IACP,YAAY;IACZ,OAAO;IACP,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,cAAc;IACd,QAAQ;IACR,UAAU;IAEV,oBAAoB;IACpB,kBAAkB;IA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AAM;IACN,OAAO;IACP,OAAO;IACP,QAAQ;IACR,OAAO;IACP,UAAU;CACX,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Match `name` against the glob `pattern` (Go filepath.Match semantics). */
2
+ export declare function matchName(pattern: string, name: string): boolean;
3
+ //# sourceMappingURL=match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.d.ts","sourceRoot":"","sources":["../../../src/client/ignore/match.ts"],"names":[],"mappings":"AAeA,6EAA6E;AAC7E,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAOhE"}
@@ -0,0 +1,166 @@
1
+ // Faithful port of Go's path/filepath Match, used by the gitignore pattern
2
+ // engine to match a single glob against a single path component.
3
+ //
4
+ // The separator is fixed to "/" (paths are normalized to forward slashes and
5
+ // individual components never contain a separator). Matching operates on UTF-16
6
+ // code units rather than runes — correct for the ASCII glob syntax gitignore
7
+ // patterns use; exotic multi-byte classes are out of scope.
8
+ //
9
+ // Go returns ErrBadPattern for malformed patterns; every go-git caller treats
10
+ // that as "no match", so `matchName` swallows the error and returns false.
11
+ const SEPARATOR = "/";
12
+ class BadPatternError extends Error {
13
+ }
14
+ /** Match `name` against the glob `pattern` (Go filepath.Match semantics). */
15
+ export function matchName(pattern, name) {
16
+ try {
17
+ return matchImpl(pattern, name);
18
+ }
19
+ catch (err) {
20
+ if (err instanceof BadPatternError)
21
+ return false;
22
+ throw err;
23
+ }
24
+ }
25
+ function matchImpl(pattern, name) {
26
+ outer: while (pattern.length > 0) {
27
+ const [star, chunk, rest] = scanChunk(pattern);
28
+ pattern = rest;
29
+ if (star && chunk === "") {
30
+ // Trailing `*` matches the rest of the component (which has no separator).
31
+ return !name.includes(SEPARATOR);
32
+ }
33
+ const [t, ok] = matchChunk(chunk, name);
34
+ if (ok && (t.length === 0 || pattern.length > 0)) {
35
+ name = t;
36
+ continue;
37
+ }
38
+ if (star) {
39
+ for (let i = 0; i < name.length && name[i] !== SEPARATOR; i++) {
40
+ const [t2, ok2] = matchChunk(chunk, name.slice(i + 1));
41
+ if (ok2) {
42
+ if (pattern.length === 0 && t2.length > 0)
43
+ continue;
44
+ name = t2;
45
+ continue outer;
46
+ }
47
+ }
48
+ }
49
+ return false;
50
+ }
51
+ return name.length === 0;
52
+ }
53
+ function scanChunk(pattern) {
54
+ let star = false;
55
+ while (pattern.length > 0 && pattern[0] === "*") {
56
+ pattern = pattern.slice(1);
57
+ star = true;
58
+ }
59
+ let inrange = false;
60
+ let i = 0;
61
+ scan: for (i = 0; i < pattern.length; i++) {
62
+ switch (pattern[i]) {
63
+ case "\\":
64
+ if (i + 1 < pattern.length)
65
+ i++;
66
+ break;
67
+ case "[":
68
+ inrange = true;
69
+ break;
70
+ case "]":
71
+ inrange = false;
72
+ break;
73
+ case "*":
74
+ if (!inrange)
75
+ break scan;
76
+ break;
77
+ }
78
+ }
79
+ return [star, pattern.slice(0, i), pattern.slice(i)];
80
+ }
81
+ function matchChunk(chunk, s) {
82
+ let failed = false;
83
+ while (chunk.length > 0) {
84
+ if (!failed && s.length === 0)
85
+ failed = true;
86
+ const c = chunk[0];
87
+ if (c === "[") {
88
+ let r = "";
89
+ if (!failed) {
90
+ r = s[0] ?? "";
91
+ s = s.slice(1);
92
+ }
93
+ chunk = chunk.slice(1);
94
+ let negated = false;
95
+ if (chunk.length > 0 && chunk[0] === "^") {
96
+ negated = true;
97
+ chunk = chunk.slice(1);
98
+ }
99
+ let match = false;
100
+ let nrange = 0;
101
+ for (;;) {
102
+ if (chunk.length > 0 && chunk[0] === "]" && nrange > 0) {
103
+ chunk = chunk.slice(1);
104
+ break;
105
+ }
106
+ let lo;
107
+ [lo, chunk] = getEsc(chunk);
108
+ let hi = lo;
109
+ if (chunk[0] === "-") {
110
+ [hi, chunk] = getEsc(chunk.slice(1));
111
+ }
112
+ if (lo <= r && r <= hi)
113
+ match = true;
114
+ nrange++;
115
+ }
116
+ if (match === negated)
117
+ failed = true;
118
+ }
119
+ else if (c === "?") {
120
+ if (!failed) {
121
+ if (s[0] === SEPARATOR)
122
+ failed = true;
123
+ s = s.slice(1);
124
+ }
125
+ chunk = chunk.slice(1);
126
+ }
127
+ else if (c === "\\") {
128
+ chunk = chunk.slice(1);
129
+ if (chunk.length === 0)
130
+ throw new BadPatternError("bad pattern");
131
+ if (!failed) {
132
+ if (chunk[0] !== s[0])
133
+ failed = true;
134
+ s = s.slice(1);
135
+ }
136
+ chunk = chunk.slice(1);
137
+ }
138
+ else {
139
+ if (!failed) {
140
+ if (chunk[0] !== s[0])
141
+ failed = true;
142
+ s = s.slice(1);
143
+ }
144
+ chunk = chunk.slice(1);
145
+ }
146
+ }
147
+ if (failed)
148
+ return ["", false];
149
+ return [s, true];
150
+ }
151
+ function getEsc(chunk) {
152
+ if (chunk.length === 0 || chunk[0] === "-" || chunk[0] === "]") {
153
+ throw new BadPatternError("bad pattern");
154
+ }
155
+ if (chunk[0] === "\\") {
156
+ chunk = chunk.slice(1);
157
+ if (chunk.length === 0)
158
+ throw new BadPatternError("bad pattern");
159
+ }
160
+ const r = chunk[0] ?? "";
161
+ const nchunk = chunk.slice(1);
162
+ if (nchunk.length === 0)
163
+ throw new BadPatternError("bad pattern");
164
+ return [r, nchunk];
165
+ }
166
+ //# sourceMappingURL=match.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"match.js","sourceRoot":"","sources":["../../../src/client/ignore/match.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,iEAAiE;AACjE,EAAE;AACF,6EAA6E;AAC7E,gFAAgF;AAChF,6EAA6E;AAC7E,4DAA4D;AAC5D,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAE3E,MAAM,SAAS,GAAG,GAAG,CAAC;AAEtB,MAAM,eAAgB,SAAQ,KAAK;CAAG;AAEtC,6EAA6E;AAC7E,MAAM,UAAU,SAAS,CAAC,OAAe,EAAE,IAAY;IACrD,IAAI,CAAC;QACH,OAAO,SAAS,CAAC,OAAO,EA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AG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC;YACD,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACzB,CAAC;IACH,CAAC;IACD,IAAI,MAAM;QAAE,OAAO,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;IAC/B,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;AACnB,CAAC;AAED,SAAS,MAAM,CAAC,KAAa;IAC3B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;QAC/D,MAAM,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;IACD,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACtB,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACzB,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;IAClE,OAAO,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;AACrB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { type Pattern } from "./pattern.js";
2
+ export declare const SOURCE_DEFAULTS = "defaults";
3
+ export declare const SOURCE_GITIGNORE = ".gitignore";
4
+ export declare const SOURCE_STIGMERIGNORE = ".stigmerignore";
5
+ export declare const SOURCE_CLI = "cli";
6
+ export declare enum Reason {
7
+ NoMatch = 0,
8
+ Excluded = 1,
9
+ Included = 2,
10
+ DefaultDeny = 3
11
+ }
12
+ export declare const REASON_TEXT: Readonly<Record<Reason, string>>;
13
+ export interface MatchReason {
14
+ readonly ignored: boolean;
15
+ readonly reason: Reason;
16
+ readonly source: string;
17
+ readonly pattern: string;
18
+ }
19
+ interface PatternEntry {
20
+ readonly pattern: Pattern;
21
+ readonly source: string;
22
+ readonly raw: string;
23
+ }
24
+ /** The pattern sources a matcher is built from, in precedence order (later wins). */
25
+ export interface IgnoreSources {
26
+ /** Whether the built-in security defaults apply (every push says yes). */
27
+ readonly includeDefaults: boolean;
28
+ /** The text of the root `.gitignore`, or `undefined` when absent or not respected. */
29
+ readonly gitignore?: string;
30
+ /** The text of the root `.stigmerignore`, or `undefined` when absent. */
31
+ readonly stigmerignore?: string;
32
+ /** Extra exclusion patterns from the caller (`--ignore`). */
33
+ readonly extraIgnore?: readonly string[];
34
+ /** Extra inclusion patterns from the caller (`--include`), negated if not already. */
35
+ readonly extraInclude?: readonly string[];
36
+ }
37
+ export declare class Matcher {
38
+ private readonly entries;
39
+ constructor(entries: readonly PatternEntry[]);
40
+ /** Decide whether a path (relative, forward-slash) is ignored, with reason. */
41
+ matchWithReason(path: string, isDir: boolean): MatchReason;
42
+ /** Whether the path should be excluded from the artifact. */
43
+ match(path: string, isDir: boolean): boolean;
44
+ /** All loaded patterns as "[source] pattern" (for dry-run diagnostics). */
45
+ patterns(): string[];
46
+ }
47
+ /** Build a matcher from its sources; the pure core every reader shares. */
48
+ export declare function buildMatcher(sources: IgnoreSources): Matcher;
49
+ export {};
50
+ //# sourceMappingURL=matcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matcher.d.ts","sourceRoot":"","sources":["../../../src/client/ignore/matcher.ts"],"names":[],"mappings":"AAYA,OAAO,EAAe,KAAK,OAAO,EAAgB,MAAM,cAAc,CAAC;AAEvE,eAAO,MAAM,eAAe,aAAa,CAAC;AAC1C,eAAO,MAAM,gBAAgB,eAAe,CAAC;AAC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K,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO;IAI5C,2EAA2E;IAC3E,QAAQ,IAAI,MAAM,EAAE;CAGrB;AAED,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAmB5D"}
@@ -0,0 +1,116 @@
1
+ // Ignore matcher: composes pattern sources with gitignore precedence (defaults
2
+ // → .gitignore → .stigmerignore → caller flags), evaluating "last match wins".
3
+ // A faithful port of the Go CLI's pkg/ignore Matcher.
4
+ //
5
+ // The matcher is pure over the TEXT of the ignore files. Where that text
6
+ // comes from is the caller's edge: the CLI reads `.gitignore` and
7
+ // `.stigmerignore` from the directory it is about to package, the console
8
+ // finds them among the files a marketplace tree lists. Both build the same
9
+ // matcher from the same sources, which is what makes a plugin selected in
10
+ // the browser the same set of files the CLI would have selected.
11
+ import { DEFAULT_PATTERNS } from "./defaults.js";
12
+ import { MatchResult, parsePattern } from "./pattern.js";
13
+ export const SOURCE_DEFAULTS = "defaults";
14
+ export const SOURCE_GITIGNORE = ".gitignore";
15
+ export const SOURCE_STIGMERIGNORE = ".stigmerignore";
16
+ export const SOURCE_CLI = "cli";
17
+ export var Reason;
18
+ (function (Reason) {
19
+ Reason[Reason["NoMatch"] = 0] = "NoMatch";
20
+ Reason[Reason["Excluded"] = 1] = "Excluded";
21
+ Reason[Reason["Included"] = 2] = "Included";
22
+ Reason[Reason["DefaultDeny"] = 3] = "DefaultDeny";
23
+ })(Reason || (Reason = {}));
24
+ export const REASON_TEXT = {
25
+ [Reason.NoMatch]: "no pattern matched",
26
+ [Reason.Excluded]: "excluded by pattern",
27
+ [Reason.Included]: "included by negation pattern",
28
+ [Reason.DefaultDeny]: "excluded by security default",
29
+ };
30
+ export class Matcher {
31
+ entries;
32
+ constructor(entries) {
33
+ this.entries = entries;
34
+ }
35
+ /** Decide whether a path (relative, forward-slash) is ignored, with reason. */
36
+ matchWithReason(path, isDir) {
37
+ const components = pathToComponents(path);
38
+ if (components.length === 0) {
39
+ return { ignored: false, reason: Reason.NoMatch, source: "", pattern: "" };
40
+ }
41
+ let lastMatch;
42
+ let lastResult = MatchResult.NoMatch;
43
+ for (const entry of this.entries) {
44
+ const result = entry.pattern.match(components, isDir);
45
+ if (result !== MatchResult.NoMatch) {
46
+ lastMatch = entry;
47
+ lastResult = result;
48
+ }
49
+ }
50
+ if (lastMatch === undefined) {
51
+ return { ignored: false, reason: Reason.NoMatch, source: "", pattern: "" };
52
+ }
53
+ if (lastResult === MatchResult.Exclude) {
54
+ const reason = lastMatch.source === SOURCE_DEFAULTS ? Reason.DefaultDeny : Reason.Excluded;
55
+ return { ignored: true, reason, source: lastMatch.source, pattern: lastMatch.raw };
56
+ }
57
+ // Include (negation): explicitly un-ignored.
58
+ return { ignored: false, reason: Reason.Included, source: lastMatch.source, pattern: lastMatch.raw };
59
+ }
60
+ /** Whether the path should be excluded from the artifact. */
61
+ match(path, isDir) {
62
+ return this.matchWithReason(path, isDir).ignored;
63
+ }
64
+ /** All loaded patterns as "[source] pattern" (for dry-run diagnostics). */
65
+ patterns() {
66
+ return this.entries.map((entry) => `[${entry.source}] ${entry.raw}`);
67
+ }
68
+ }
69
+ /** Build a matcher from its sources; the pure core every reader shares. */
70
+ export function buildMatcher(sources) {
71
+ const entries = [];
72
+ if (sources.includeDefaults) {
73
+ entries.push(...parseEntries(DEFAULT_PATTERNS, SOURCE_DEFAULTS));
74
+ }
75
+ if (sources.gitignore !== undefined) {
76
+ entries.push(...parseEntries(sources.gitignore.split(/\r?\n/), SOURCE_GITIGNORE));
77
+ }
78
+ if (sources.stigmerignore !== undefined) {
79
+ entries.push(...parseEntries(sources.stigmerignore.split(/\r?\n/), SOURCE_STIGMERIGNORE));
80
+ }
81
+ const extraIgnore = sources.extraIgnore ?? [];
82
+ const extraInclude = sources.extraInclude ?? [];
83
+ if (extraIgnore.length > 0 || extraInclude.length > 0) {
84
+ entries.push(...loadCliPatterns(extraIgnore, extraInclude));
85
+ }
86
+ return new Matcher(entries);
87
+ }
88
+ function parseEntries(patterns, source) {
89
+ const entries = [];
90
+ for (const raw of patterns) {
91
+ const trimmed = raw.trim();
92
+ if (trimmed === "" || trimmed.startsWith("#"))
93
+ continue;
94
+ entries.push({ pattern: parsePattern(trimmed, []), source, raw: trimmed });
95
+ }
96
+ return entries;
97
+ }
98
+ function loadCliPatterns(ignore, include) {
99
+ const entries = parseEntries(ignore, SOURCE_CLI);
100
+ const negations = [];
101
+ for (const pattern of include) {
102
+ const trimmed = pattern.trim();
103
+ if (trimmed === "")
104
+ continue;
105
+ negations.push(trimmed.startsWith("!") ? trimmed : `!${trimmed}`);
106
+ }
107
+ entries.push(...parseEntries(negations, SOURCE_CLI));
108
+ return entries;
109
+ }
110
+ function pathToComponents(path) {
111
+ const normalized = path.replace(/\\/g, "/").replace(/^\.\//, "");
112
+ if (normalized === "" || normalized === ".")
113
+ return [];
114
+ return normalized.split("/");
115
+ }
116
+ //# sourceMappingURL=matcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matcher.js","sourceRoot":"","sources":["../../../src/client/ignore/matcher.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,+EAA+E;AAC/E,sDAAsD;AACtD,EAAE;AACF,yEAAyE;AACzE,kEAAkE;AAClE,0EAA0E;AAC1E,2EAA2E;AAC3E,0EAA0E;AAC1E,iEAAiE;AAEjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,WAAW,EAAgB,YAAY,EAAE,MAAM,cAAc,CAAC;AAEvE,MAAM,CAAC,MAAM,eAAe,GAAG,UAAU,CAAC;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAC7C,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC;AACrD,MAAM,CAAC,MAAM,UAAU,GAAG,KAAK,CAAC;AAEhC,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,y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AAG,YAAY,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACjD,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,OAAO,KAAK,EAAE;YAAE,SAAS;QAC7B,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,OAAO,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC;IACrD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACjE,IAAI,UAAU,KAAK,EAAE,IAAI,UAAU,KAAK,GAAG;QAAE,OAAO,EAAE,CAAC;IACvD,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,13 @@
1
+ export declare enum MatchResult {
2
+ NoMatch = 0,
3
+ Exclude = 1,
4
+ Include = 2
5
+ }
6
+ export interface Pattern {
7
+ /** Whether this is a negation (`!`) pattern — needed for source ordering. */
8
+ readonly inclusion: boolean;
9
+ match(path: readonly string[], isDir: boolean): MatchResult;
10
+ }
11
+ /** Parse a gitignore pattern string into a matchable Pattern (go-git parity). */
12
+ export declare function parsePattern(raw: string, domain: readonly string[]): Pattern;
13
+ //# sourceMappingURL=pattern.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pattern.d.ts","sourceRoot":"","sources":["../../../src/client/ignore/pattern.ts"],"names":[],"mappings":"AAOA,oBAAY,WAAW;IACrB,OAAO,IAAI;IACX,OAAO,IAAI;IACX,OAAO,IAAI;CACZ;AAMD,MAAM,WAAW,OAAO;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,KAAK,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,GAAG,WAAW,CAAC;CAC7D;AAsFD,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAsB5E"}