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 @@
1
+ {"version":3,"file":"hosted-api.js","sourceRoot":"","sources":["../src/hosted-api.ts"],"names":[],"mappings":"AAAA,+HAA+H;AAC/H,kGAAkG;AAClG,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,2HAA2H;AAC3H,MAAM,CAAC,MAAM,eAAe,GAAG,qCAAqC,CAAC;AAErE,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAiD,EAAE,aAA6B;IAC5G,IAAI,GAAG,CAAC,cAAc,KAAK,SAAS;QAAE,OAAO,GAAG,CAAC,cAAc,CAAC;IAChE,OAAO,aAAa,KAAK,SAAS,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CA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AAC;gBACrE,IAAI,IAAI,KAAK,SAAS;oBAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;gBACtE,IAAI,CAAC;oBACH,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAY,EAAE,CAAC;gBACzD,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,CAAC;gBAChD,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,EAAE,CAAC;YACzE,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Prompter } from "./prompter.js";
2
+ /**
3
+ * Asks whether to send `fileCount` files (`kb` KB) to the API for AI questions. True means send.
4
+ * With `withDecision` the question also names the latest DECISIONS.md entry (Task 13); the KB figure counts the code files only.
5
+ */
6
+ export declare function askSendCode(prompter: Prompter, host: string, fileCount: number, kb: string, withDecision?: boolean): Promise<boolean>;
7
+ /** Asks whether to send the typed answers to the API for grading. True means send. */
8
+ export declare function askSendAnswers(prompter: Prompter, host: string): Promise<boolean>;
@@ -0,0 +1,37 @@
1
+ // The Yes/No question before code or answers go to the Seance API (Task 8, decision D1 by Vedant Nov 30):
2
+ // asked once per run, "Yes" preselected. Used by `seance quiz` and `seance review`.
3
+ import { toPlainText } from "@seance/core";
4
+ import { plural } from "./quiz-ui.js";
5
+ const YES = "yes";
6
+ const NO = "no";
7
+ /**
8
+ * Asks whether to send `fileCount` files (`kb` KB) to the API for AI questions. True means send.
9
+ * With `withDecision` the question also names the latest DECISIONS.md entry (Task 13); the KB figure counts the code files only.
10
+ */
11
+ export async function askSendCode(prompter, host, fileCount, kb, withDecision = false) {
12
+ const extra = withDecision ? " and the latest DECISIONS.md entry" : "";
13
+ const answer = await prompter.select({
14
+ id: "consent:send-code",
15
+ message: toPlainText(`Send ${fileCount} ${plural(fileCount, "file", "files")} (${kb} KB)${extra} to the Seance API (${host}) for AI questions? It passes them to Gemini, NVIDIA or OpenRouter.`),
16
+ choices: [
17
+ { value: YES, name: "Yes, send" },
18
+ { value: NO, name: "No, use questions from the code structure" },
19
+ ],
20
+ default: YES,
21
+ });
22
+ return answer === YES;
23
+ }
24
+ /** Asks whether to send the typed answers to the API for grading. True means send. */
25
+ export async function askSendAnswers(prompter, host) {
26
+ const answer = await prompter.select({
27
+ id: "consent:send-answers",
28
+ message: toPlainText(`Send your answers to the Seance API (${host}) for grading?`),
29
+ choices: [
30
+ { value: YES, name: "Yes, send" },
31
+ { value: NO, name: "No, grade by keywords" },
32
+ ],
33
+ default: YES,
34
+ });
35
+ return answer === YES;
36
+ }
37
+ //# sourceMappingURL=hosted-consent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosted-consent.js","sourceRoot":"","sources":["../src/hosted-consent.ts"],"names":[],"mappings":"AAAA,0GAA0G;AAC1G,oFAAoF;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,MAAM,GAAG,GAAG,KAAK,CAAC;AAClB,MAAM,EAAE,GAAG,IAAI,CAAC;AAEhB;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAkB,EAAE,IAAY,EAAE,SAAiB,EAAE,EAAU,EAAE,YAAY,GAAG,KAAK;IACrH,MAAM,KAAK,GAAG,YAAY,CAAC,CAAC,CAAC,oCAAoC,CAAC,CAAC,CAAC,EAAE,CAAC;IACvE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACnC,EAAE,EAAE,mBAAmB;QACvB,OAAO,EAAE,WAAW,CAAC,QAAQ,SAAS,IAAI,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,KAAK,uBAAuB,IAAI,qEAAqE,CAAC;QAChM,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE;YACjC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,2CAA2C,EAAE;SACjE;QACD,OAAO,EAAE,GAAG;KACb,CAAC,CAAC;IACH,OAAO,MAAM,KAAK,GAAG,CAAC;AACxB,CAAC;AAED,sFAAsF;AACtF,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,QAAkB,EAAE,IAAY;IACnE,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;QACnC,EAAE,EAAE,sBAAsB;QAC1B,OAAO,EAAE,WAAW,CAAC,wCAAwC,IAAI,gBAAgB,CAAC;QAClF,OAAO,EAAE;YACP,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE;YACjC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,uBAAuB,EAAE;SAC7C;QACD,OAAO,EAAE,GAAG;KACb,CAAC,CAAC;IACH,OAAO,MAAM,KAAK,GAAG,CAAC;AACxB,CAAC"}
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ // Entry point of the `seance` command: builds the commander program and wires `init`, `sync`, `quiz`, `review` and `mcp` to the real terminal.
3
+ // One file per command in ./commands. `mcp` writes only protocol messages to stdout and its log lines to stderr.
4
+ import { randomBytes } from "node:crypto";
5
+ import { readFile } from "node:fs/promises";
6
+ import { Command } from "commander";
7
+ import { runInit } from "./commands/init.js";
8
+ import { runMcp } from "./commands/mcp.js";
9
+ import { runQuiz } from "./commands/quiz.js";
10
+ import { runReview } from "./commands/review.js";
11
+ import { runSync } from "./commands/sync.js";
12
+ import { createInquirerPrompter } from "./prompter.js";
13
+ /** The version in this package's package.json (one folder above both `src/` and `dist/`). */
14
+ async function readVersion() {
15
+ const text = await readFile(new URL("../package.json", import.meta.url), "utf8");
16
+ const parsed = JSON.parse(text);
17
+ const version = typeof parsed === "object" && parsed !== null ? parsed.version : undefined;
18
+ return typeof version === "string" ? version : "0.0.0";
19
+ }
20
+ async function main() {
21
+ const version = await readVersion();
22
+ const program = new Command();
23
+ program.name("seance").description("Rules for AI agents, a self-updating PROJECT.md, and quizzes on what the AI built.").version(version);
24
+ program
25
+ .command("init")
26
+ .description("Set up agent rules, PROJECT.md, hooks and the dependency guard for a project")
27
+ .option("--dir <path>", "folder to set up (default: the current folder)")
28
+ .option("--yes", "ask nothing; use flags, stored answers, detected values and defaults")
29
+ .option("--dry-run", "show what would be written and write nothing")
30
+ .option("--targets <list>", "comma-separated: kiro, agents-md (default: both)")
31
+ .option("--gate <mode>", "learning gate: off, soft or strict (default: strict)")
32
+ .option("--name <text>", "project name")
33
+ .option("--description <text>", "what the project does, in one sentence")
34
+ .option("--audience <text>", "who will use it")
35
+ .option("--language <name>", "TypeScript or JavaScript")
36
+ .option("--framework <name>", "main framework")
37
+ .option("--package-manager <name>", "npm, pnpm, yarn or bun")
38
+ .option("--test-runner <name>", "vitest, jest, node:test, mocha or none")
39
+ .option("--experience <level>", "beginner, intermediate or experienced")
40
+ .option("--out-of-scope <text>", "what the AI must not build")
41
+ .option("--conventions <text>", "extra rules for the AI")
42
+ .action(async (options) => {
43
+ process.exitCode = await runInit(options, {
44
+ cwd: process.cwd(),
45
+ prompter: createInquirerPrompter(),
46
+ isTTY: process.stdin.isTTY === true,
47
+ out: (line) => console.log(line),
48
+ version,
49
+ });
50
+ });
51
+ program
52
+ .command("sync")
53
+ .description("Update PROJECT.md and save a quiz on the latest change")
54
+ .option("--dir <path>", "project folder (default: the current folder)")
55
+ .option("--dry-run", "show the new auto section and write nothing")
56
+ .action(async (options) => {
57
+ process.exitCode = await runSync(options, { cwd: process.cwd(), out: (line) => console.log(line), now: () => new Date() });
58
+ });
59
+ program
60
+ .command("quiz")
61
+ .description("Quiz yourself on the latest change")
62
+ .option("--dir <path>", "project folder (default: the current folder)")
63
+ .option("--offline", "make questions from the code structure only; send nothing to an AI provider")
64
+ .action(async (options) => {
65
+ process.exitCode = await runQuiz(options, {
66
+ cwd: process.cwd(),
67
+ out: (line) => console.log(line),
68
+ prompter: createInquirerPrompter(),
69
+ isTTY: process.stdin.isTTY === true,
70
+ now: () => new Date(),
71
+ env: process.env,
72
+ });
73
+ });
74
+ program
75
+ .command("review")
76
+ .description("Review missed concepts that are due")
77
+ .option("--dir <path>", "project folder (default: the current folder)")
78
+ .option("--offline", "grade explain cards by keywords; send nothing to an AI provider")
79
+ .action(async (options) => {
80
+ process.exitCode = await runReview(options, {
81
+ cwd: process.cwd(),
82
+ out: (line) => console.log(line),
83
+ prompter: createInquirerPrompter(),
84
+ isTTY: process.stdin.isTTY === true,
85
+ now: () => new Date(),
86
+ env: process.env,
87
+ });
88
+ });
89
+ program
90
+ .command("mcp")
91
+ .description("Serve the Seance tools to an AI agent over MCP (stdio)")
92
+ .option("--dir <path>", "project folder (default: the current folder)")
93
+ .action(async (options) => {
94
+ process.exitCode = await runMcp(options, {
95
+ cwd: process.cwd(),
96
+ err: (line) => process.stderr.write(`${line}\n`),
97
+ now: () => new Date(),
98
+ randomId: () => `mq_${randomBytes(8).toString("hex")}`,
99
+ version,
100
+ });
101
+ });
102
+ await program.parseAsync(process.argv);
103
+ }
104
+ main().catch((error) => {
105
+ console.error(`seance: ${error instanceof Error ? error.message : String(error)}`);
106
+ process.exitCode = 1;
107
+ });
108
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,+IAA+I;AAC/I,iHAAiH;AACjH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;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AQ,GAAG,CAAC,CAAC;AACvB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,51 @@
1
+ import type { Existing, InitPlan, Manifest, PlannedWrite } from "@seance/core";
2
+ /** Why a path counts as `other`: it is skipped as foreign and never touched. */
3
+ export type OtherReason = "not-utf8" | "too-large" | "not-a-file" | "unsafe-path" | "unreadable";
4
+ /** What `readExisting` found. It is assignable to core's `Existing` (the plan ignores `why`); `why` is only for messages. */
5
+ export type ReadResult = {
6
+ type: "file";
7
+ content: string;
8
+ } | {
9
+ type: "other";
10
+ why: OtherReason;
11
+ };
12
+ /** The four file operations of a write. Tests replace some of them to make a write fail at a chosen step. */
13
+ export interface WriteOps {
14
+ mkdir(path: string): Promise<void>;
15
+ writeFile(path: string, content: string): Promise<void>;
16
+ rename(from: string, to: string): Promise<void>;
17
+ rm(path: string): Promise<void>;
18
+ }
19
+ export declare const REAL_WRITE_OPS: WriteOps;
20
+ /** The error code of a failed file operation (`ENOENT`, `UNSAFE_PATH`...), never a stack. */
21
+ export declare function errorCode(error: unknown): string;
22
+ /** The real path of the target folder, resolved once; every later path is built under it. */
23
+ export declare function resolveRoot(dir: string): Promise<string>;
24
+ /**
25
+ * Looks at every parent folder of `relPath` below the root, outermost first.
26
+ * "ok": all exist as real folders. "absent": one is missing, so nothing below it exists.
27
+ * "unsafe": one is a symlink or junction, exists but is not a folder, or cannot be read.
28
+ */
29
+ export declare function checkParents(fsRoot: string, relPath: string): Promise<"ok" | "absent" | "unsafe">;
30
+ /**
31
+ * What is at `relPath` (a POSIX path under the root): nothing (undefined), a regular UTF-8 file up to `maxBytes`,
32
+ * or `other` (symlink, folder, too large, not UTF-8, unreadable, or below a symlink or a file).
33
+ */
34
+ export declare function readExisting(fsRoot: string, relPath: string, maxBytes: number): Promise<ReadResult | undefined>;
35
+ /**
36
+ * Writes `content` to `relPath` through a temporary file in the same folder and a rename, so a crash never leaves half a file.
37
+ * Checks the parent folders before the `mkdir` and again before the rename, and checks that the target is still what the
38
+ * plan was made from (`expected`: undefined = absent, a string = that exact text). Returns "changed" without writing when it
39
+ * is not. The temporary file is removed on every failure. Throws on a write error or an unsafe path.
40
+ */
41
+ export declare function writeAtomic(fsRoot: string, relPath: string, content: string, expected: string | undefined, ops?: WriteOps): Promise<"written" | "changed">;
42
+ /** What `applyPlan` did: a label for every write that was skipped at the last moment, and whether a write failed. */
43
+ export interface ApplyResult {
44
+ labels: Map<PlannedWrite, string>;
45
+ failed: boolean;
46
+ }
47
+ /**
48
+ * Writes every planned write in order, the manifest last. A target that changed since it was read is skipped and labelled.
49
+ * On a write error: prints the path and error code through `out`, saves a partial manifest and reports `failed`.
50
+ */
51
+ export declare function applyPlan(fsRoot: string, plan: InitPlan, existing: ReadonlyMap<string, Existing>, before: Manifest, out: (line: string) => void, overrides?: Partial<WriteOps>): Promise<ApplyResult>;
@@ -0,0 +1,220 @@
1
+ // File-system helpers of `seance init`: read what is in the target folder (strict UTF-8, no symlinked parent folders),
2
+ // write one file safely (temporary file, parent and target re-checks, rename) and apply a whole plan, manifest last.
3
+ // The only I/O of init besides prompts.
4
+ import { lstat, mkdir, readFile, realpath, rename, rm, writeFile } from "node:fs/promises";
5
+ import { dirname, join } from "node:path";
6
+ import { MANIFEST_PATH } from "@seance/core";
7
+ export const REAL_WRITE_OPS = {
8
+ mkdir: async (path) => {
9
+ await mkdir(path, { recursive: true });
10
+ },
11
+ writeFile: (path, content) => writeFile(path, content, { encoding: "utf8", flag: "wx" }),
12
+ rename,
13
+ rm: (path) => rm(path, { force: true }),
14
+ };
15
+ // Strict decoder: invalid bytes throw instead of becoming U+FFFD. ignoreBOM keeps a leading BOM in the text.
16
+ const UTF8 = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
17
+ /** The text of the bytes, or undefined when they are not valid UTF-8. */
18
+ function decodeUtf8(bytes) {
19
+ try {
20
+ return UTF8.decode(bytes);
21
+ }
22
+ catch {
23
+ return undefined;
24
+ }
25
+ }
26
+ /** The error code of a failed file operation (`ENOENT`, `UNSAFE_PATH`...), never a stack. */
27
+ export function errorCode(error) {
28
+ const code = error?.code;
29
+ return typeof code === "string" ? code : "UNKNOWN";
30
+ }
31
+ /** The real path of the target folder, resolved once; every later path is built under it. */
32
+ export function resolveRoot(dir) {
33
+ return realpath(dir);
34
+ }
35
+ /** The absolute path of a POSIX path under the root. */
36
+ function absolutePath(fsRoot, relPath) {
37
+ return join(fsRoot, ...relPath.split("/"));
38
+ }
39
+ /**
40
+ * Looks at every parent folder of `relPath` below the root, outermost first.
41
+ * "ok": all exist as real folders. "absent": one is missing, so nothing below it exists.
42
+ * "unsafe": one is a symlink or junction, exists but is not a folder, or cannot be read.
43
+ */
44
+ export async function checkParents(fsRoot, relPath) {
45
+ let current = fsRoot;
46
+ for (const part of relPath.split("/").slice(0, -1)) {
47
+ current = join(current, part);
48
+ try {
49
+ const info = await lstat(current);
50
+ if (info.isSymbolicLink() || !info.isDirectory())
51
+ return "unsafe";
52
+ }
53
+ catch (error) {
54
+ return errorCode(error) === "ENOENT" ? "absent" : "unsafe";
55
+ }
56
+ }
57
+ return "ok";
58
+ }
59
+ /**
60
+ * What is at `relPath` (a POSIX path under the root): nothing (undefined), a regular UTF-8 file up to `maxBytes`,
61
+ * or `other` (symlink, folder, too large, not UTF-8, unreadable, or below a symlink or a file).
62
+ */
63
+ export async function readExisting(fsRoot, relPath, maxBytes) {
64
+ const parents = await checkParents(fsRoot, relPath);
65
+ if (parents === "absent")
66
+ return undefined;
67
+ if (parents === "unsafe")
68
+ return { type: "other", why: "unsafe-path" };
69
+ const full = absolutePath(fsRoot, relPath);
70
+ let info;
71
+ try {
72
+ info = await lstat(full);
73
+ }
74
+ catch (error) {
75
+ return errorCode(error) === "ENOENT" ? undefined : { type: "other", why: "unreadable" };
76
+ }
77
+ if (!info.isFile())
78
+ return { type: "other", why: "not-a-file" };
79
+ if (info.size > maxBytes)
80
+ return { type: "other", why: "too-large" };
81
+ try {
82
+ const content = decodeUtf8(await readFile(full));
83
+ return content === undefined ? { type: "other", why: "not-utf8" } : { type: "file", content };
84
+ }
85
+ catch {
86
+ return { type: "other", why: "unreadable" };
87
+ }
88
+ }
89
+ /** True when the target is still what the plan was made from: absent when `expected` is undefined, else a file with that text. */
90
+ async function targetUnchanged(full, expected) {
91
+ let info;
92
+ try {
93
+ info = await lstat(full);
94
+ }
95
+ catch (error) {
96
+ return errorCode(error) === "ENOENT" && expected === undefined;
97
+ }
98
+ if (expected === undefined || !info.isFile() || info.size !== Buffer.byteLength(expected))
99
+ return false;
100
+ try {
101
+ return decodeUtf8(await readFile(full)) === expected;
102
+ }
103
+ catch {
104
+ return false;
105
+ }
106
+ }
107
+ /** Throws a coded error when a parent folder is unsafe (or, with `mustExist`, missing). */
108
+ async function requireSafeParents(fsRoot, relPath, mustExist) {
109
+ const state = await checkParents(fsRoot, relPath);
110
+ if (state === "unsafe" || (mustExist && state === "absent")) {
111
+ throw Object.assign(new Error(`${relPath}: a parent folder is a symlink, a junction or not a folder`), { code: "UNSAFE_PATH" });
112
+ }
113
+ }
114
+ let tempCounter = 0;
115
+ /**
116
+ * Writes `content` to `relPath` through a temporary file in the same folder and a rename, so a crash never leaves half a file.
117
+ * Checks the parent folders before the `mkdir` and again before the rename, and checks that the target is still what the
118
+ * plan was made from (`expected`: undefined = absent, a string = that exact text). Returns "changed" without writing when it
119
+ * is not. The temporary file is removed on every failure. Throws on a write error or an unsafe path.
120
+ */
121
+ export async function writeAtomic(fsRoot, relPath, content, expected, ops = REAL_WRITE_OPS) {
122
+ const full = absolutePath(fsRoot, relPath);
123
+ await requireSafeParents(fsRoot, relPath, false);
124
+ await ops.mkdir(dirname(full));
125
+ await requireSafeParents(fsRoot, relPath, true); // the folders now exist: check they are still real folders
126
+ tempCounter += 1;
127
+ const temp = `${full}.seance-tmp-${process.pid}-${tempCounter}`;
128
+ try {
129
+ await ops.writeFile(temp, content);
130
+ await requireSafeParents(fsRoot, relPath, true);
131
+ if (!(await targetUnchanged(full, expected))) {
132
+ await ops.rm(temp);
133
+ return "changed";
134
+ }
135
+ await ops.rename(temp, full);
136
+ return "written";
137
+ }
138
+ catch (error) {
139
+ await ops.rm(temp).catch(() => undefined);
140
+ throw error;
141
+ }
142
+ }
143
+ // ---------------------------------------------------------------------------------------------------------------
144
+ // Applying a plan
145
+ const RULES_KEY = "AGENTS.md#rules";
146
+ const CHANGED_LABEL = "skipped (changed during init)";
147
+ /** True for a planned write that puts text on disk. */
148
+ function isWrite(write) {
149
+ const writes = ["create", "update", "append-markers", "append-rules"];
150
+ return writes.includes(write.action) && write.content !== undefined;
151
+ }
152
+ /** The text a path had when the plan was made (undefined: it was absent), so the write can check it did not change. */
153
+ function textBefore(existing, path) {
154
+ const found = existing.get(path);
155
+ return found?.type === "file" ? found.content : undefined;
156
+ }
157
+ /**
158
+ * The manifest text after the writes that happened: the planned manifest, with the earlier record (or none) put back
159
+ * for every write that has a record and did not happen (failed, never reached, or changed during init) (9.3, 5.11).
160
+ */
161
+ function manifestAfter(before, plan, written) {
162
+ const records = { ...plan.manifest.records };
163
+ for (const write of plan.writes) {
164
+ if (write.record === undefined || written.has(write))
165
+ continue;
166
+ const key = write.path === "AGENTS.md" ? RULES_KEY : write.path;
167
+ const earlier = before.records[key];
168
+ if (earlier === undefined)
169
+ delete records[key];
170
+ else
171
+ records[key] = earlier;
172
+ }
173
+ const sorted = Object.fromEntries(Object.entries(records).sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
174
+ return JSON.stringify({ schemaVersion: 1, records: sorted }, null, 2) + "\n";
175
+ }
176
+ /**
177
+ * Writes every planned write in order, the manifest last. A target that changed since it was read is skipped and labelled.
178
+ * On a write error: prints the path and error code through `out`, saves a partial manifest and reports `failed`.
179
+ */
180
+ export async function applyPlan(fsRoot, plan, existing, before, out, overrides) {
181
+ const ops = { ...REAL_WRITE_OPS, ...overrides };
182
+ const written = new Set();
183
+ const labels = new Map();
184
+ for (const write of plan.writes) {
185
+ if (!isWrite(write))
186
+ continue;
187
+ const isManifest = write.path === MANIFEST_PATH;
188
+ const content = isManifest ? manifestAfter(before, plan, written) : write.content;
189
+ try {
190
+ const outcome = await writeAtomic(fsRoot, write.path, content, textBefore(existing, write.path), ops);
191
+ if (outcome === "written")
192
+ written.add(write);
193
+ else
194
+ labels.set(write, CHANGED_LABEL);
195
+ }
196
+ catch (error) {
197
+ out(`could not write ${write.path}: ${errorCode(error)}`);
198
+ if (!isManifest)
199
+ await writePartialManifest(fsRoot, plan, existing, before, written, ops, out);
200
+ return { labels, failed: true };
201
+ }
202
+ }
203
+ return { labels, failed: false };
204
+ }
205
+ /**
206
+ * After a failed write: save a manifest that has a record for every file written so far and the earlier record
207
+ * for every file not written (9.3). It goes through the same checks as every write, and is not written over a manifest
208
+ * path that is a symlink or not a regular file (5.9). Failure to save it is reported but does not change the exit code.
209
+ */
210
+ async function writePartialManifest(fsRoot, plan, existing, before, written, ops, out) {
211
+ if (existing.get(MANIFEST_PATH)?.type === "other")
212
+ return;
213
+ try {
214
+ await writeAtomic(fsRoot, MANIFEST_PATH, manifestAfter(before, plan, written), textBefore(existing, MANIFEST_PATH), ops);
215
+ }
216
+ catch (error) {
217
+ out(`could not write ${MANIFEST_PATH}: ${errorCode(error)}`);
218
+ }
219
+ }
220
+ //# sourceMappingURL=init-fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-fs.js","sourceRoot":"","sources":["../src/init-fs.ts"],"names":[],"mappings":"AAAA,uHAAuH;AACvH,qHAAqH;AACrH,wCAAwC;AACxC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAiB7C,MAAM,CAAC,MAAM,cAAc,GAAa;IACtC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,E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AAI,KAAK,OAAO;QAAE,OAAO;IAC1D,IAAI,CAAC;QACH,MAAM,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,QAAQ,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,CAAC;IAC3H,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,mBAAmB,aAAa,KAAK,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Detected, GateMode, InitAnswers } from "@seance/core";
2
+ import type { Prompter } from "./prompter.js";
3
+ /** Everything that can answer a question before the user does. */
4
+ export interface KnownAnswers {
5
+ flags: InitAnswers;
6
+ stored: InitAnswers;
7
+ detected: Detected;
8
+ prompter: Prompter;
9
+ }
10
+ /**
11
+ * `--yes`: per item the flag, else the stored answer, else the detected value, else the default, else nothing (1.3).
12
+ * The detected description is never used (open question 46): it stays undecided unless `--description` is given.
13
+ */
14
+ export declare function answersWithoutQuestions(known: KnownAnswers): InitAnswers;
15
+ /** Items nobody answered: a required one is recorded as undecided (so the generated files list it), an optional one is left out. */
16
+ export declare function withUndecided(answers: InitAnswers): InitAnswers;
17
+ /** Asks every item (a flag answers its own item), then the gate mode, then the missing required items once more (2.5). */
18
+ export declare function askEverything(known: KnownAnswers, gateFlag: GateMode | undefined, gateDefault: GateMode, out: (line: string) => void): Promise<{
19
+ answers: InitAnswers;
20
+ gateMode: GateMode;
21
+ }>;