seance-cli 0.0.0-stage → 0.1.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 (190) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -2
  3. package/dist/commands/init.d.ts +29 -0
  4. package/dist/commands/init.js +310 -0
  5. package/dist/commands/init.js.map +1 -0
  6. package/dist/commands/mcp.d.ts +19 -0
  7. package/dist/commands/mcp.js +38 -0
  8. package/dist/commands/mcp.js.map +1 -0
  9. package/dist/commands/quiz.d.ts +23 -0
  10. package/dist/commands/quiz.js +187 -0
  11. package/dist/commands/quiz.js.map +1 -0
  12. package/dist/commands/review.d.ts +4 -0
  13. package/dist/commands/review.js +115 -0
  14. package/dist/commands/review.js.map +1 -0
  15. package/dist/commands/sync.d.ts +17 -0
  16. package/dist/commands/sync.js +367 -0
  17. package/dist/commands/sync.js.map +1 -0
  18. package/dist/git.d.ts +33 -0
  19. package/dist/git.js +103 -0
  20. package/dist/git.js.map +1 -0
  21. package/dist/hosted-api.d.ts +24 -0
  22. package/dist/hosted-api.js +85 -0
  23. package/dist/hosted-api.js.map +1 -0
  24. package/dist/hosted-consent.d.ts +8 -0
  25. package/dist/hosted-consent.js +37 -0
  26. package/dist/hosted-consent.js.map +1 -0
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.js +108 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/init-fs.d.ts +51 -0
  31. package/dist/init-fs.js +220 -0
  32. package/dist/init-fs.js.map +1 -0
  33. package/dist/init-questions.d.ts +21 -0
  34. package/dist/init-questions.js +161 -0
  35. package/dist/init-questions.js.map +1 -0
  36. package/dist/mcp-handlers.d.ts +22 -0
  37. package/dist/mcp-handlers.js +185 -0
  38. package/dist/mcp-handlers.js.map +1 -0
  39. package/dist/mcp-server.d.ts +4 -0
  40. package/dist/mcp-server.js +39 -0
  41. package/dist/mcp-server.js.map +1 -0
  42. package/dist/prompter.d.ts +29 -0
  43. package/dist/prompter.js +42 -0
  44. package/dist/prompter.js.map +1 -0
  45. package/dist/quiz-backend.d.ts +40 -0
  46. package/dist/quiz-backend.js +116 -0
  47. package/dist/quiz-backend.js.map +1 -0
  48. package/dist/quiz-input.d.ts +12 -0
  49. package/dist/quiz-input.js +52 -0
  50. package/dist/quiz-input.js.map +1 -0
  51. package/dist/quiz-io.d.ts +30 -0
  52. package/dist/quiz-io.js +83 -0
  53. package/dist/quiz-io.js.map +1 -0
  54. package/dist/quiz-ui.d.ts +18 -0
  55. package/dist/quiz-ui.js +51 -0
  56. package/dist/quiz-ui.js.map +1 -0
  57. package/node_modules/@seance/ai/LICENSE +21 -0
  58. package/node_modules/@seance/ai/dist/chain.d.ts +31 -0
  59. package/node_modules/@seance/ai/dist/chain.js +114 -0
  60. package/node_modules/@seance/ai/dist/chain.js.map +1 -0
  61. package/node_modules/@seance/ai/dist/grade.d.ts +14 -0
  62. package/node_modules/@seance/ai/dist/grade.js +44 -0
  63. package/node_modules/@seance/ai/dist/grade.js.map +1 -0
  64. package/node_modules/@seance/ai/dist/hosted-config.d.ts +9 -0
  65. package/node_modules/@seance/ai/dist/hosted-config.js +27 -0
  66. package/node_modules/@seance/ai/dist/hosted-config.js.map +1 -0
  67. package/node_modules/@seance/ai/dist/index.d.ts +9 -0
  68. package/node_modules/@seance/ai/dist/index.js +9 -0
  69. package/node_modules/@seance/ai/dist/index.js.map +1 -0
  70. package/node_modules/@seance/ai/dist/providers.d.ts +54 -0
  71. package/node_modules/@seance/ai/dist/providers.js +149 -0
  72. package/node_modules/@seance/ai/dist/providers.js.map +1 -0
  73. package/node_modules/@seance/ai/dist/quiz.d.ts +26 -0
  74. package/node_modules/@seance/ai/dist/quiz.js +41 -0
  75. package/node_modules/@seance/ai/dist/quiz.js.map +1 -0
  76. package/node_modules/@seance/ai/package.json +25 -0
  77. package/node_modules/@seance/core/LICENSE +21 -0
  78. package/node_modules/@seance/core/dist/ai-check.d.ts +58 -0
  79. package/node_modules/@seance/core/dist/ai-check.js +460 -0
  80. package/node_modules/@seance/core/dist/ai-check.js.map +1 -0
  81. package/node_modules/@seance/core/dist/ai-prompts.d.ts +29 -0
  82. package/node_modules/@seance/core/dist/ai-prompts.js +221 -0
  83. package/node_modules/@seance/core/dist/ai-prompts.js.map +1 -0
  84. package/node_modules/@seance/core/dist/ai-schemas.d.ts +155 -0
  85. package/node_modules/@seance/core/dist/ai-schemas.js +92 -0
  86. package/node_modules/@seance/core/dist/ai-schemas.js.map +1 -0
  87. package/node_modules/@seance/core/dist/api-client.d.ts +26 -0
  88. package/node_modules/@seance/core/dist/api-client.js +71 -0
  89. package/node_modules/@seance/core/dist/api-client.js.map +1 -0
  90. package/node_modules/@seance/core/dist/api-errors.d.ts +37 -0
  91. package/node_modules/@seance/core/dist/api-errors.js +66 -0
  92. package/node_modules/@seance/core/dist/api-errors.js.map +1 -0
  93. package/node_modules/@seance/core/dist/api-schemas.d.ts +284 -0
  94. package/node_modules/@seance/core/dist/api-schemas.js +67 -0
  95. package/node_modules/@seance/core/dist/api-schemas.js.map +1 -0
  96. package/node_modules/@seance/core/dist/decision-log.d.ts +73 -0
  97. package/node_modules/@seance/core/dist/decision-log.js +239 -0
  98. package/node_modules/@seance/core/dist/decision-log.js.map +1 -0
  99. package/node_modules/@seance/core/dist/dependency-guard.d.ts +20 -0
  100. package/node_modules/@seance/core/dist/dependency-guard.js +732 -0
  101. package/node_modules/@seance/core/dist/dependency-guard.js.map +1 -0
  102. package/node_modules/@seance/core/dist/gate.d.ts +11 -0
  103. package/node_modules/@seance/core/dist/gate.js +26 -0
  104. package/node_modules/@seance/core/dist/gate.js.map +1 -0
  105. package/node_modules/@seance/core/dist/git-parse.d.ts +11 -0
  106. package/node_modules/@seance/core/dist/git-parse.js +23 -0
  107. package/node_modules/@seance/core/dist/git-parse.js.map +1 -0
  108. package/node_modules/@seance/core/dist/index.d.ts +65 -0
  109. package/node_modules/@seance/core/dist/index.js +47 -0
  110. package/node_modules/@seance/core/dist/index.js.map +1 -0
  111. package/node_modules/@seance/core/dist/init-checklist.d.ts +153 -0
  112. package/node_modules/@seance/core/dist/init-checklist.js +200 -0
  113. package/node_modules/@seance/core/dist/init-checklist.js.map +1 -0
  114. package/node_modules/@seance/core/dist/init-detect.d.ts +9 -0
  115. package/node_modules/@seance/core/dist/init-detect.js +84 -0
  116. package/node_modules/@seance/core/dist/init-detect.js.map +1 -0
  117. package/node_modules/@seance/core/dist/init-templates.d.ts +36 -0
  118. package/node_modules/@seance/core/dist/init-templates.js +257 -0
  119. package/node_modules/@seance/core/dist/init-templates.js.map +1 -0
  120. package/node_modules/@seance/core/dist/map-basics.d.ts +13 -0
  121. package/node_modules/@seance/core/dist/map-basics.js +19 -0
  122. package/node_modules/@seance/core/dist/map-basics.js.map +1 -0
  123. package/node_modules/@seance/core/dist/map-summary.d.ts +5 -0
  124. package/node_modules/@seance/core/dist/map-summary.js +50 -0
  125. package/node_modules/@seance/core/dist/map-summary.js.map +1 -0
  126. package/node_modules/@seance/core/dist/markers.d.ts +51 -0
  127. package/node_modules/@seance/core/dist/markers.js +84 -0
  128. package/node_modules/@seance/core/dist/markers.js.map +1 -0
  129. package/node_modules/@seance/core/dist/mcp-quiz.d.ts +94 -0
  130. package/node_modules/@seance/core/dist/mcp-quiz.js +130 -0
  131. package/node_modules/@seance/core/dist/mcp-quiz.js.map +1 -0
  132. package/node_modules/@seance/core/dist/mcp-tools.d.ts +82 -0
  133. package/node_modules/@seance/core/dist/mcp-tools.js +136 -0
  134. package/node_modules/@seance/core/dist/mcp-tools.js.map +1 -0
  135. package/node_modules/@seance/core/dist/mcp-views.d.ts +21 -0
  136. package/node_modules/@seance/core/dist/mcp-views.js +83 -0
  137. package/node_modules/@seance/core/dist/mcp-views.js.map +1 -0
  138. package/node_modules/@seance/core/dist/quiz-assembly.d.ts +21 -0
  139. package/node_modules/@seance/core/dist/quiz-assembly.js +43 -0
  140. package/node_modules/@seance/core/dist/quiz-assembly.js.map +1 -0
  141. package/node_modules/@seance/core/dist/quiz-cards.d.ts +183 -0
  142. package/node_modules/@seance/core/dist/quiz-cards.js +215 -0
  143. package/node_modules/@seance/core/dist/quiz-cards.js.map +1 -0
  144. package/node_modules/@seance/core/dist/quiz-session.d.ts +67 -0
  145. package/node_modules/@seance/core/dist/quiz-session.js +141 -0
  146. package/node_modules/@seance/core/dist/quiz-session.js.map +1 -0
  147. package/node_modules/@seance/core/dist/quiz-subjects.d.ts +13 -0
  148. package/node_modules/@seance/core/dist/quiz-subjects.js +63 -0
  149. package/node_modules/@seance/core/dist/quiz-subjects.js.map +1 -0
  150. package/node_modules/@seance/core/dist/rate-limit.d.ts +33 -0
  151. package/node_modules/@seance/core/dist/rate-limit.js +114 -0
  152. package/node_modules/@seance/core/dist/rate-limit.js.map +1 -0
  153. package/node_modules/@seance/core/dist/scoring.d.ts +48 -0
  154. package/node_modules/@seance/core/dist/scoring.js +95 -0
  155. package/node_modules/@seance/core/dist/scoring.js.map +1 -0
  156. package/node_modules/@seance/core/dist/seance-config.d.ts +177 -0
  157. package/node_modules/@seance/core/dist/seance-config.js +43 -0
  158. package/node_modules/@seance/core/dist/seance-config.js.map +1 -0
  159. package/node_modules/@seance/core/dist/seance-state.d.ts +125 -0
  160. package/node_modules/@seance/core/dist/seance-state.js +61 -0
  161. package/node_modules/@seance/core/dist/seance-state.js.map +1 -0
  162. package/node_modules/@seance/core/dist/sm2.d.ts +18 -0
  163. package/node_modules/@seance/core/dist/sm2.js +87 -0
  164. package/node_modules/@seance/core/dist/sm2.js.map +1 -0
  165. package/node_modules/@seance/core/dist/stored-schemas.d.ts +29 -0
  166. package/node_modules/@seance/core/dist/stored-schemas.js +29 -0
  167. package/node_modules/@seance/core/dist/stored-schemas.js.map +1 -0
  168. package/node_modules/@seance/core/dist/structural-questions.d.ts +31 -0
  169. package/node_modules/@seance/core/dist/structural-questions.js +575 -0
  170. package/node_modules/@seance/core/dist/structural-questions.js.map +1 -0
  171. package/node_modules/@seance/core/dist/structure-map-schema.d.ts +84 -0
  172. package/node_modules/@seance/core/dist/structure-map-schema.js +73 -0
  173. package/node_modules/@seance/core/dist/structure-map-schema.js.map +1 -0
  174. package/node_modules/@seance/core/dist/structure-map.d.ts +78 -0
  175. package/node_modules/@seance/core/dist/structure-map.js +750 -0
  176. package/node_modules/@seance/core/dist/structure-map.js.map +1 -0
  177. package/node_modules/@seance/core/dist/sync-changes.d.ts +38 -0
  178. package/node_modules/@seance/core/dist/sync-changes.js +89 -0
  179. package/node_modules/@seance/core/dist/sync-changes.js.map +1 -0
  180. package/node_modules/@seance/core/dist/sync-render.d.ts +28 -0
  181. package/node_modules/@seance/core/dist/sync-render.js +113 -0
  182. package/node_modules/@seance/core/dist/sync-render.js.map +1 -0
  183. package/node_modules/@seance/core/dist/terminal-text.d.ts +8 -0
  184. package/node_modules/@seance/core/dist/terminal-text.js +33 -0
  185. package/node_modules/@seance/core/dist/terminal-text.js.map +1 -0
  186. package/node_modules/@seance/core/dist/write-plan.d.ts +51 -0
  187. package/node_modules/@seance/core/dist/write-plan.js +173 -0
  188. package/node_modules/@seance/core/dist/write-plan.js.map +1 -0
  189. package/node_modules/@seance/core/package.json +26 -0
  190. package/package.json +42 -6
@@ -0,0 +1,239 @@
1
+ // The DECISIONS.md format: parse a log, render an entry, and compare logs between syncs (Task 13).
2
+ // Pure and never throws on data. Used by `seance sync`, `seance quiz`, the hosted API and the AI prompt.
3
+ import { z } from "zod";
4
+ import { toPlainText } from "./terminal-text.js";
5
+ import { contentHash } from "./write-plan.js";
6
+ export const DECISIONS_PATH = "DECISIONS.md";
7
+ export const DECISION_LIMITS = {
8
+ maxFileBytes: 262_144, // callers read the file with at most this many bytes
9
+ maxEntries: 200, // the last ones are kept
10
+ maxTitleChars: 200,
11
+ maxFieldChars: 1_000,
12
+ maxPromptChars: 4_096,
13
+ };
14
+ export const DECISION_FIELDS = ["built", "stuck", "options", "chose", "why", "openQuestions"];
15
+ export const DECISION_LABELS = {
16
+ built: "Built",
17
+ stuck: "Stuck",
18
+ options: "Options",
19
+ chose: "Chose",
20
+ why: "Why",
21
+ openQuestions: "Open questions",
22
+ };
23
+ // ---------------------------------------------------------------------------
24
+ // Cleaning text to one line
25
+ // ---------------------------------------------------------------------------
26
+ // Control characters and the line and paragraph separators.
27
+ const LINE_BREAKERS = /[\x00-\x1f\x7f-\x9f\u2028\u2029]/g;
28
+ function cutChars(text, max) {
29
+ if (text.length <= max)
30
+ return text;
31
+ return Array.from(text).slice(0, max).join("");
32
+ }
33
+ /** One line: control characters become spaces, whitespace runs collapse, the text is trimmed and cut. */
34
+ function cleanLine(text, max) {
35
+ return cutChars(text.replace(LINE_BREAKERS, " ").replace(/\s+/g, " ").trim(), max).trimEnd();
36
+ }
37
+ /** Removes `<!--` and `-->` until none is left, so a rendered entry cannot open or close a comment. */
38
+ function stripCommentMarkers(text) {
39
+ let result = text;
40
+ for (;;) {
41
+ const next = result.split("<!--").join("").split("-->").join("");
42
+ if (next === result)
43
+ return result;
44
+ result = next;
45
+ }
46
+ }
47
+ // ---------------------------------------------------------------------------
48
+ // Parsing
49
+ // ---------------------------------------------------------------------------
50
+ const HEADING = /^## (\d{4}-\d{2}-\d{2}) Task ([A-Za-z0-9][A-Za-z0-9._-]{0,19}): ([\s\S]*)$/;
51
+ // Up to the colon only; the value is the rest of the line (so a value that starts with `**` keeps it).
52
+ const FIELD_START = /^[-*]\s+(\*\*)?(built|stuck|options|chose|why|open questions)(?:\*\*)?\s*:/i;
53
+ const FIELD_BY_LABEL = {
54
+ built: "built",
55
+ stuck: "stuck",
56
+ options: "options",
57
+ chose: "chose",
58
+ why: "why",
59
+ "open questions": "openQuestions",
60
+ };
61
+ /** Up to 3 leading spaces, then three backticks or three tildes: the fence marker, or undefined. */
62
+ function fenceMarker(line) {
63
+ let at = 0;
64
+ while (at < 3 && line[at] === " ")
65
+ at += 1;
66
+ const marker = line.slice(at, at + 3);
67
+ return marker === "```" || marker === "~~~" ? marker : undefined;
68
+ }
69
+ /**
70
+ * Reads the entries of a DECISIONS.md text. One pass over the lines, never throws.
71
+ * Lines inside HTML comments and fenced code blocks are ignored; any other line outside an entry is ignored.
72
+ */
73
+ export function parseDecisionLog(text) {
74
+ const lines = String(text).split(/\r\n|\n|\r/);
75
+ const raws = [];
76
+ let total = 0; // every heading with a title, also those cut by the entry cap
77
+ let current; // the entry being read; undefined outside an entry
78
+ let field; // the value being collected, if any
79
+ let inComment = false; // inside an HTML comment that spans lines
80
+ let fence; // the marker of the open code fence, if any
81
+ for (let index = 0; index < lines.length; index += 1) {
82
+ const line = lines[index] ?? "";
83
+ if (inComment) {
84
+ if (line.includes("-->"))
85
+ inComment = false;
86
+ field = undefined;
87
+ continue;
88
+ }
89
+ if (fence !== undefined) {
90
+ if (fenceMarker(line) === fence)
91
+ fence = undefined;
92
+ field = undefined;
93
+ continue;
94
+ }
95
+ const opening = fenceMarker(line);
96
+ if (opening !== undefined) {
97
+ fence = opening;
98
+ field = undefined;
99
+ continue;
100
+ }
101
+ const trimmed = line.trimStart();
102
+ if (trimmed.startsWith("<!--")) {
103
+ if (!trimmed.includes("-->", 4))
104
+ inComment = true;
105
+ field = undefined;
106
+ continue;
107
+ }
108
+ const heading = HEADING.exec(line);
109
+ if (heading !== null) {
110
+ const title = cleanLine(heading[3] ?? "", DECISION_LIMITS.maxTitleChars);
111
+ if (title !== "") {
112
+ total += 1;
113
+ current = { date: heading[1] ?? "", task: heading[2] ?? "", title, line: index + 1, fields: {} };
114
+ raws.push(current);
115
+ field = undefined;
116
+ continue;
117
+ }
118
+ }
119
+ if (line.startsWith("#")) {
120
+ current = undefined; // another heading ends the entry
121
+ field = undefined;
122
+ continue;
123
+ }
124
+ if (current === undefined)
125
+ continue;
126
+ const start = FIELD_START.exec(line);
127
+ if (start !== null) {
128
+ const key = FIELD_BY_LABEL[(start[2] ?? "").toLowerCase()];
129
+ let value = line.slice(start[0].length);
130
+ if (start[1] !== undefined && value.trimStart().startsWith("**"))
131
+ value = value.trimStart().slice(2); // `- **Why:** x`
132
+ if (key === undefined || current.fields[key] !== undefined) {
133
+ field = undefined; // a repeated label keeps the first value
134
+ }
135
+ else {
136
+ field = [value];
137
+ current.fields[key] = field;
138
+ }
139
+ continue;
140
+ }
141
+ if (field !== undefined && line.trim() !== "" && (line.startsWith(" ") || line.startsWith("\t"))) {
142
+ field.push(line.trim());
143
+ continue;
144
+ }
145
+ field = undefined;
146
+ }
147
+ const entries = raws.slice(-DECISION_LIMITS.maxEntries).map((raw) => {
148
+ const fields = {};
149
+ for (const key of DECISION_FIELDS) {
150
+ const parts = raw.fields[key];
151
+ if (parts === undefined)
152
+ continue;
153
+ const value = cleanLine(parts.join(" "), DECISION_LIMITS.maxFieldChars);
154
+ if (value !== "")
155
+ fields[key] = value;
156
+ }
157
+ return { date: raw.date, task: raw.task, title: raw.title, fields, line: raw.line };
158
+ });
159
+ return { entries, total };
160
+ }
161
+ /** The last entry by position (not by date). */
162
+ export function latestDecision(log) {
163
+ return log.entries.at(-1);
164
+ }
165
+ /** `none` (any case, with or without a full stop) says there is nothing, so it does not count as a value. */
166
+ function isNone(value) {
167
+ return /^none\.?$/i.test(value.trim());
168
+ }
169
+ /** True when the entry says what was chosen and why (both present and not `none`). */
170
+ export function hasChoice(entry) {
171
+ const { chose, why } = entry.fields;
172
+ return chose !== undefined && why !== undefined && !isNone(chose) && !isNone(why);
173
+ }
174
+ // ---------------------------------------------------------------------------
175
+ // Rendering
176
+ // ---------------------------------------------------------------------------
177
+ /** The heading and the six bullets of an entry, one line each, ending with a line break. */
178
+ export function renderDecisionEntry(entry) {
179
+ const title = cleanLine(stripCommentMarkers(entry.title), DECISION_LIMITS.maxTitleChars);
180
+ const lines = [`## ${entry.date} Task ${entry.task}: ${title === "" ? "untitled" : title}`];
181
+ for (const key of DECISION_FIELDS) {
182
+ const raw = entry.fields[key];
183
+ const value = raw === undefined ? "" : cleanLine(stripCommentMarkers(raw), DECISION_LIMITS.maxFieldChars);
184
+ lines.push(`- ${DECISION_LABELS[key]}: ${value === "" ? "none" : value}`);
185
+ }
186
+ return `${lines.join("\n")}\n`;
187
+ }
188
+ /** The only form of an entry an AI prompt may contain: plain text, line breaks kept, at most 4 096 characters. */
189
+ export function decisionPromptText(entry) {
190
+ return stripCommentMarkers(toPlainText(renderDecisionEntry(entry), { keepNewlines: true, maxChars: DECISION_LIMITS.maxPromptChars }));
191
+ }
192
+ /** A short hash of the heading (date, task, title). Used to notice that the latest entry changed. */
193
+ export function decisionKey(entry) {
194
+ return contentHash(`${entry.date} Task ${entry.task}: ${entry.title}`);
195
+ }
196
+ // ---------------------------------------------------------------------------
197
+ // What `seance sync` remembers between runs
198
+ // ---------------------------------------------------------------------------
199
+ export const DecisionLogStateSchema = z.object({
200
+ count: z.int().min(0).max(1_000_000),
201
+ latestKey: z.string().regex(/^fnv1a32:[0-9a-f]{8}$/).nullable(),
202
+ });
203
+ export function decisionLogState(log) {
204
+ const latest = latestDecision(log);
205
+ return { count: log.total, latestKey: latest === undefined ? null : decisionKey(latest) };
206
+ }
207
+ /** `baseline` without a stored state; `new-entry` when the count grew or the latest heading changed. */
208
+ export function compareDecisionLog(stored, log) {
209
+ if (stored === undefined)
210
+ return "baseline";
211
+ if (log.total > stored.count)
212
+ return "new-entry";
213
+ const latest = latestDecision(log);
214
+ if (latest !== undefined && decisionKey(latest) !== stored.latestKey)
215
+ return "new-entry";
216
+ return "no-new-entry";
217
+ }
218
+ export const DECISION_LINES = {
219
+ missing: "DECISIONS.md not found; run seance init to create it",
220
+ other: "DECISIONS.md skipped (not a regular UTF-8 file under 256 KB)",
221
+ none: "no new entry in DECISIONS.md since the last sync; the agent should add one after each task",
222
+ };
223
+ /**
224
+ * The decision check of `seance sync`: the one line to print (without the `seance sync: ` prefix) and the state to store.
225
+ * `next` undefined means keep the stored value. `stored` is the raw `decisionLog` of the state file; a bad value is a baseline.
226
+ */
227
+ export function decisionCheck(read, stored) {
228
+ if (read.type === "missing")
229
+ return { line: DECISION_LINES.missing, next: { count: 0, latestKey: null } };
230
+ if (read.type === "other")
231
+ return { line: DECISION_LINES.other };
232
+ const log = parseDecisionLog(read.text);
233
+ const parsed = DecisionLogStateSchema.safeParse(stored);
234
+ const next = decisionLogState(log);
235
+ if (compareDecisionLog(parsed.success ? parsed.data : undefined, log) === "no-new-entry")
236
+ return { line: DECISION_LINES.none, next };
237
+ return { next };
238
+ }
239
+ //# sourceMappingURL=decision-log.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decision-log.js","sourceRoot":"","sources":["../src/decision-log.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,yGAAyG;AACzG,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,MAAM,CAAC,MAAM,cAAc,GAAG,cAAc,CAAC;AAE7C,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,YAAY,EAAE,OAAO,EAAE,qDAAqD;IAC5E,UAAU,EAAE,GAAG,EAAE,yBAAyB;IAC1C,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,KAAK;IACpB,cAAc,EAAE,KAAK;CACb,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,eAAe,CAAU,CAAC;AAGvG,MAAM,CAAC,MAAM,eAAe,GAAkC;IAC5D,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;IACd,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,GAAG,EAAE,KAAK;IACV,aAAa,EAAE,gBAAgB;CAChC,CAAC;AAgBF,8EAA8E;AAC9E,4BAA4B;AAC5B,8EAA8E;AAE9E,4DAA4D;AAC5D,MAAM,aAAa,GAAG,mCAAmC,CAAC;AAE1D,SAAS,QAAQ,CAAC,IAAY,EAAE,GAAW;IACzC,IAAI,IAAI,CAAC,MAA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,KAAK,SAAS;QAAE,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,EAAE,CAAC;IAC1G,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,KAAK,EAAE,CAAC;IACjE,MAAM,GAAG,GAAG,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,sBAAsB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,kBAAkB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,EAAE,GAAG,CAAC,KAAK,cAAc;QAAE,OAAO,EAAE,IAAI,EAAE,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC;IACrI,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC"}
@@ -0,0 +1,20 @@
1
+ export interface GuardVerdict {
2
+ verdict: "allow" | "block";
3
+ packages: string[];
4
+ }
5
+ /** The text the guard writes to stderr when it blocks (the model reads it). */
6
+ export declare function guardMessage(packages: string[]): string;
7
+ /**
8
+ * Decides whether a shell command may run. The command is read as a POSIX shell and as PowerShell would read it, and
9
+ * blocked when either reading blocks (open question 48). It blocks when any segment adds a registry package whose name is not in
10
+ * `allow`, or any package that is not a registry spec (a URL, `owner/repo`, `zod@npm:evil`), which `allow` cannot approve.
11
+ * Installs from the lockfile or from a local path (no package named) and every other command are allowed. Never throws.
12
+ */
13
+ export declare function classifyShellCommand(command: string, allow: readonly string[]): GuardVerdict;
14
+ /**
15
+ * The guard as a plain Node ESM script (only `node:` imports), written to `.kiro/seance/dependency-guard.mjs`.
16
+ * Same rules as `classifyShellCommand`; the differential test (P10) runs the real script against the function.
17
+ * Written with String.raw so backslashes reach the file untouched. Keep backticks and dollar-brace out of it:
18
+ * the backtick is written as the escape x60 inside a string, and the script never has a dollar sign before a brace.
19
+ */
20
+ export declare const DEPENDENCY_GUARD_SCRIPT: string;