@joshuafolkken/kit 1.1005.0 → 1.1035.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 (272) hide show
  1. package/.claude/settings.json +1 -5
  2. package/.claude/skills/dependency-update/SKILL.md +6 -3
  3. package/.claude/skills/epic-commands/SKILL.md +46 -17
  4. package/.claude/skills/workflow-commands/SKILL.md +8 -23
  5. package/.claude/skills/workflow-commands/backlogrun-child.md +4 -2
  6. package/.claude/skills/workflow-commands/backlogrun.md +3 -12
  7. package/.claude/skills/workflow-commands/fullrun-steps.md +4 -3
  8. package/.claude/skills/workflow-commands/fullrun.md +1 -1
  9. package/.claude/skills/workflow-commands/halfrun.md +2 -1
  10. package/.claude/skills/workflow-commands/into-target.md +1 -1
  11. package/.claude/skills/workflow-commands/observation-filing.md +42 -43
  12. package/.claude/skills/workflow-commands/prerequisite.md +1 -1
  13. package/.codex/hooks.json +1 -5
  14. package/.github/workflows/sonar-qube.yml +1 -1
  15. package/AGENTS.md +4 -25
  16. package/CLAUDE.md +24 -38
  17. package/GEMINI.md +4 -24
  18. package/README.md +22 -58
  19. package/dist/CLAUDE.md +24 -38
  20. package/dist/hooks/batch-guard.js +4 -4
  21. package/dist/hooks/{chunk-WMIR5SNX.js → chunk-D67KVGGY.js} +3 -3
  22. package/dist/hooks/{chunk-EZLHXKJ6.js → chunk-EIFCAJRB.js} +70 -27
  23. package/dist/hooks/{chunk-KPZN42RT.js → chunk-GJT4BNVE.js} +3 -3
  24. package/dist/hooks/{chunk-PAXMLGSS.js → chunk-GLBDBJOK.js} +44 -24
  25. package/dist/hooks/{chunk-GBJUERYK.js → chunk-HOYJU5RM.js} +1 -1
  26. package/dist/hooks/{chunk-6PSTVOLH.js → chunk-HU66PWWL.js} +33 -57
  27. package/dist/hooks/{chunk-A2H5I2VD.js → chunk-KG6PZD72.js} +2 -2
  28. package/dist/hooks/{chunk-AWTFKKFW.js → chunk-XPLP27WA.js} +3 -8
  29. package/dist/hooks/{chunk-4GDR2YTV.js → chunk-Y27M6A7X.js} +4 -4
  30. package/dist/hooks/{chunk-56LGMJJV.js → chunk-ZXNE6NY3.js} +2 -2
  31. package/dist/hooks/codex-hook-adapter.js +10 -10
  32. package/dist/hooks/duplicate-read-guard.js +5 -5
  33. package/dist/hooks/format-edited.js +2 -2
  34. package/dist/hooks/investigation-guard.js +5 -5
  35. package/dist/hooks/pretool-guard.js +9 -9
  36. package/dist/hooks/stop-guard.js +11 -15
  37. package/dist/josh.js +38 -19
  38. package/dist/version/index.js +93 -41
  39. package/eslint/base.js +2 -11
  40. package/package.json +32 -6
  41. package/prompts/coding-standards.md +15 -290
  42. package/prompts/collaboration-workflow/cross-repo-epic.md +2 -51
  43. package/prompts/collaboration-workflow/epic-audit.md +2 -53
  44. package/prompts/collaboration-workflow/epic-bundle.md +2 -106
  45. package/prompts/collaboration-workflow/issue-template.md +4 -4
  46. package/prompts/collaboration-workflow/operating-rules.md +18 -75
  47. package/prompts/collaboration-workflow/principles.md +74 -0
  48. package/prompts/collaboration-workflow/residency.md +54 -14
  49. package/prompts/collaboration-workflow/rule-delivery.md +1 -11
  50. package/prompts/collaboration-workflow/upstream-interrupt.md +1 -1
  51. package/prompts/collaboration-workflow.md +22 -28
  52. package/scripts/adopt/adopt-logic.ts +2 -2
  53. package/scripts/adopt/adopt-toolkits.ts +1 -1
  54. package/scripts/adopt/adopt.ts +2 -2
  55. package/scripts/agent/agent-event.ts +2 -9
  56. package/scripts/agent/agent-exit-record.ts +2 -9
  57. package/scripts/backlog/backlog-budget-cli.ts +2 -6
  58. package/scripts/backlog/backlog-drive-cli.ts +20 -10
  59. package/scripts/backlog/backlog-drive.ts +50 -16
  60. package/scripts/backlog/backlog-offer-cli.ts +6 -5
  61. package/scripts/backlog/backlog-plan.ts +1 -1
  62. package/scripts/build/build-bin.ts +2 -1
  63. package/scripts/build/build-config-merge.ts +2 -1
  64. package/scripts/build/build-hooks.ts +24 -4
  65. package/scripts/build/build-managed-marker.ts +2 -1
  66. package/scripts/build/build-self-sync-guard.ts +2 -1
  67. package/scripts/build/build-version.ts +2 -1
  68. package/scripts/cases/cases-logic.ts +2 -6
  69. package/scripts/ci/pr-classification.ts +13 -11
  70. package/scripts/cost-runtime/cost-transcript.ts +4 -11
  71. package/scripts/doctor/doctor-consumer.ts +5 -12
  72. package/scripts/doctor/doctor-ports.ts +2 -2
  73. package/scripts/document/document-byte-budget.ts +8 -16
  74. package/scripts/document/document-section.ts +2 -6
  75. package/scripts/document/entry-read-budget.ts +1 -1
  76. package/scripts/{git/git-epic-add-body.ts → epic/epic-add-body.ts} +23 -23
  77. package/scripts/{git/git-epic-add-plan.ts → epic/epic-add-plan.ts} +23 -26
  78. package/scripts/{git/git-epic-add.ts → epic/epic-add.ts} +17 -17
  79. package/scripts/epic/epic-audit-cli.ts +4 -4
  80. package/scripts/epic/epic-audit-orphans.ts +2 -2
  81. package/scripts/epic/epic-audit-rationale.ts +1 -1
  82. package/scripts/epic/epic-audit.ts +1 -1
  83. package/scripts/{git/git-epic-body.ts → epic/epic-body.ts} +6 -6
  84. package/scripts/epic/epic-bundle-cli.ts +1 -1
  85. package/scripts/epic/epic-bundle.ts +2 -2
  86. package/scripts/epic/epic-candidate-confirm.ts +2 -1
  87. package/scripts/{git/git-epic-chains.ts → epic/epic-chains.ts} +4 -4
  88. package/{scripts-ai → scripts/epic}/epic-check.ts +5 -4
  89. package/{scripts-ai → scripts/epic}/epic-cli.ts +4 -4
  90. package/scripts/{git/git-epic-close-comment.ts → epic/epic-close-comment.ts} +9 -9
  91. package/scripts/{git/git-epic-close.ts → epic/epic-close.ts} +23 -19
  92. package/scripts/epic/epic-cross-repo.ts +21 -38
  93. package/scripts/{git/git-epic-decision.ts → epic/epic-decision.ts} +12 -14
  94. package/scripts/epic/epic-fetch.ts +3 -3
  95. package/scripts/epic/epic-graph.ts +3 -3
  96. package/scripts/epic/epic-index.ts +2 -2
  97. package/scripts/epic/epic-issue.ts +1 -1
  98. package/scripts/epic/epic-next.ts +3 -3
  99. package/scripts/{git/git-epic-parse.ts → epic/epic-parse.ts} +3 -3
  100. package/scripts/{git/git-epic-promote.ts → epic/epic-promote.ts} +10 -10
  101. package/scripts/{git/git-epic-read.ts → epic/epic-read.ts} +9 -9
  102. package/scripts/{git/git-epic-reconcile.ts → epic/epic-reconcile.ts} +18 -20
  103. package/scripts/{git/git-epic-reference.ts → epic/epic-reference.ts} +4 -23
  104. package/scripts/epic/epic-relation-recheck.ts +4 -3
  105. package/scripts/{git/git-epic-relations.ts → epic/epic-relations.ts} +5 -5
  106. package/scripts/{git/git-epic-remove-plan.ts → epic/epic-remove-plan.ts} +17 -19
  107. package/scripts/{git/git-epic-remove.ts → epic/epic-remove.ts} +13 -13
  108. package/scripts/{git/git-epic-run.ts → epic/epic-run.ts} +27 -27
  109. package/scripts/{git/git-epic-sections.ts → epic/epic-sections.ts} +6 -6
  110. package/scripts/{git/git-epic-shape.ts → epic/epic-shape.ts} +7 -7
  111. package/scripts/{git/git-epic-validate.ts → epic/epic-validate.ts} +13 -13
  112. package/{scripts-ai → scripts/epic}/epic.ts +17 -16
  113. package/scripts/gh/fix-gh-packages.ts +2 -1
  114. package/scripts/gh/gh-spawn.ts +12 -10
  115. package/scripts/git/constants.ts +1 -1
  116. package/scripts/git/git-branch.ts +10 -1
  117. package/scripts/git/git-command.ts +1 -1
  118. package/scripts/git/git-error.ts +2 -5
  119. package/{scripts-ai → scripts/git}/git-followup-finish.ts +7 -7
  120. package/scripts/git/git-followup-flush.ts +74 -48
  121. package/scripts/git/git-followup-issue-close.ts +2 -2
  122. package/scripts/git/git-followup-label.ts +1 -1
  123. package/scripts/git/git-followup-pending.ts +1 -1
  124. package/{scripts-ai → scripts/git}/git-followup-workflow.ts +23 -11
  125. package/scripts/git/git-gh-exec.ts +85 -26
  126. package/scripts/git/git-gh-issue-read.ts +2 -2
  127. package/scripts/git/git-gh-issue-rest.ts +2 -2
  128. package/scripts/git/git-gh-issue-write.ts +6 -6
  129. package/scripts/git/git-gh-pr-read.ts +0 -21
  130. package/scripts/git/git-gh-pr.ts +2 -23
  131. package/scripts/git/git-pr-followup-wrapup.ts +2 -6
  132. package/scripts/git/git-preflight.ts +3 -6
  133. package/scripts/git/git-staging.ts +21 -9
  134. package/{scripts-ai → scripts/git}/git-workflow.ts +11 -11
  135. package/scripts/git/github-issue-url.ts +1 -1
  136. package/scripts/git/issue-labels.ts +1 -1
  137. package/scripts/git/issue-reference.ts +19 -0
  138. package/scripts/git/main-merge.ts +2 -1
  139. package/scripts/git/main-sync.ts +3 -2
  140. package/scripts/git/schemas.ts +1 -1
  141. package/scripts/git/stash-pop-args.ts +7 -13
  142. package/scripts/git/stash-pop-cli.ts +2 -1
  143. package/{scripts-ai → scripts/git}/telegram-test-logic.ts +2 -2
  144. package/{scripts-ai → scripts/git}/telegram-test.ts +7 -7
  145. package/scripts/hooks/format-rewrite-notice.ts +2 -8
  146. package/scripts/init/init-ai-copy.ts +23 -14
  147. package/scripts/init/init.ts +8 -4
  148. package/scripts/init/start-steps.ts +2 -1
  149. package/scripts/init/start.ts +2 -1
  150. package/scripts/issue/issue-comment-cli.ts +2 -1
  151. package/scripts/issue/issue-file-cli.ts +2 -1
  152. package/scripts/issue/issue-fold-cli.ts +9 -16
  153. package/scripts/issue/issue-scout-cli.ts +8 -13
  154. package/scripts/issue/measure-rerun-cli.ts +7 -6
  155. package/scripts/josh/josh-commands-ai.ts +2 -2
  156. package/scripts/josh/josh-commands-backlog.ts +1 -1
  157. package/scripts/josh/josh-commands-development.ts +1 -1
  158. package/scripts/josh/josh-commands-workflow.ts +4 -4
  159. package/scripts/lane/lane-cli.ts +2 -1
  160. package/scripts/lane/lane-open.ts +3 -2
  161. package/scripts/lane/lane-registry.ts +3 -6
  162. package/scripts/lib/cli-flags.ts +20 -2
  163. package/scripts/lib/error-message.ts +9 -0
  164. package/scripts/lib/read-file.ts +26 -2
  165. package/scripts/observations/observation-ledger-home.ts +98 -26
  166. package/scripts/observations/observation-ledger-migrate.ts +26 -21
  167. package/scripts/observations/observation-ledger-prepare.ts +10 -20
  168. package/scripts/observations/observation-ledger.ts +58 -25
  169. package/scripts/observations/observations-flush-cli.ts +6 -23
  170. package/scripts/observations/observations-flush-landing.ts +2 -1
  171. package/scripts/observations/observations-flush.ts +29 -20
  172. package/scripts/package/package-scout-cli.ts +8 -16
  173. package/scripts/ports/port-command.ts +2 -1
  174. package/scripts/propagate/propagate-publish.ts +6 -7
  175. package/scripts/propagate/propagate-steps.ts +2 -1
  176. package/scripts/propagate/propagate.ts +3 -2
  177. package/scripts/refactor/import-graph.ts +2 -6
  178. package/scripts/registry-migration/migrate.ts +3 -2
  179. package/scripts/registry-migration/user-npmrc.ts +2 -2
  180. package/scripts/release/release-cli.ts +2 -1
  181. package/scripts/repo/repo-setting.ts +10 -8
  182. package/scripts/review/review-finding-ledger.ts +3 -3
  183. package/scripts/review/review-findings-cli.ts +4 -11
  184. package/scripts/review/review-record-cli.ts +14 -11
  185. package/scripts/review/review-record.ts +6 -16
  186. package/scripts/rules/decision-oracle.ts +2 -2
  187. package/scripts/rules/rule-body-guard.ts +2 -2
  188. package/scripts/rules/rule-value-cache.ts +99 -0
  189. package/scripts/rules/rule-value-cli.ts +10 -9
  190. package/scripts/rules/rule-value.ts +1 -1
  191. package/scripts/run/run-carry-args.ts +2 -6
  192. package/scripts/run/run-carry-cli.ts +5 -7
  193. package/scripts/run/run-cut-args.ts +7 -13
  194. package/scripts/run/run-ending-cli.ts +4 -7
  195. package/scripts/run/run-event-stream.ts +2 -5
  196. package/scripts/run/run-liveness-cli.ts +4 -7
  197. package/scripts/run/run-progress-args.ts +2 -6
  198. package/scripts/run/run-progress-cli.ts +2 -1
  199. package/scripts/run/run-tail-cli.ts +3 -3
  200. package/scripts/run/run-tidy-stashes.ts +7 -14
  201. package/scripts/run/run-wake-cli.ts +2 -6
  202. package/scripts/run/run-wake-driver.ts +15 -2
  203. package/scripts/run/run-wake-session.ts +14 -4
  204. package/scripts/safe-chain/project-config.ts +3 -6
  205. package/scripts/security/security-audit-provision.ts +6 -7
  206. package/scripts/sonar/sonar-hotspots-cli.ts +2 -1
  207. package/scripts/sync/directory-copy-guard.ts +2 -1
  208. package/scripts/sync/sync-ai-files.ts +3 -3
  209. package/scripts/sync/template-source-logic.ts +3 -4
  210. package/scripts/test/e2e-retry-check.ts +3 -6
  211. package/scripts/ui/ui-routes-cli.ts +3 -6
  212. package/scripts/version/bump-version.ts +2 -1
  213. package/scripts/version/version-remote.ts +18 -27
  214. package/scripts/version/version-targets.ts +3 -3
  215. package/.claude/skills/workflow-commands/rule-residency.md +0 -267
  216. package/evals/scenarios/consult-not-execute.json +0 -20
  217. package/evals/scenarios/no-implicit-workflow.json +0 -26
  218. package/evals/scenarios/overrides-both-locations.json +0 -29
  219. package/evals/scenarios/upstream-interrupt.json +0 -23
  220. package/evals/scenarios/workflow-skill-loaded.json +0 -16
  221. package/prompts/agent-lint-protocol.json +0 -79
  222. package/prompts/agent-rules.md +0 -63
  223. package/prompts/collaboration-workflow/consultation-vs-execution.md +0 -8
  224. package/prompts/collaboration-workflow/distributed-docs.md +0 -7
  225. package/prompts/collaboration-workflow/durable-rules.md +0 -24
  226. package/prompts/collaboration-workflow/latest-first.md +0 -14
  227. package/prompts/collaboration-workflow/no-clones.md +0 -11
  228. package/prompts/collaboration-workflow/simplicity-first.md +0 -9
  229. package/prompts/collaboration-workflow/single-source-rules.md +0 -13
  230. package/scripts/build/shim-shell.ts +0 -25
  231. package/scripts/claude/skill-meta.ts +0 -37
  232. package/scripts/document/document-scan.ts +0 -108
  233. package/scripts/document/generate-catalog.ts +0 -69
  234. package/scripts/document/retired-phrases.ts +0 -143
  235. package/scripts/document/review-agent-type.ts +0 -46
  236. package/scripts/document/single-source.ts +0 -73
  237. package/scripts/git/git-fixture-workspace.ts +0 -88
  238. package/scripts/hooks/format-edited-file-fixtures.ts +0 -109
  239. package/scripts/hooks/prompt-hooks.ts +0 -38
  240. package/scripts/init/hook-command-bootstrap.ts +0 -83
  241. package/scripts/issue/issue-logic.ts +0 -50
  242. package/scripts/josh/__snapshots__/josh-command-map.test.ts.snap +0 -1227
  243. package/scripts/josh/josh-script-reader.ts +0 -11
  244. package/scripts/package/production-dependency-graph.ts +0 -68
  245. package/scripts/retrospective/retrospective-cli.ts +0 -97
  246. package/scripts/retrospective/retrospective.ts +0 -127
  247. package/scripts/rules/delivered-rules-harness.ts +0 -72
  248. package/scripts/rules/top-level-scripts-guard.ts +0 -47
  249. package/scripts/run/run-carry-flush.ts +0 -58
  250. package/scripts/run/run-transcript.golden.txt +0 -57
  251. package/scripts/run/run-wake-work.ts +0 -108
  252. package/scripts/sync/dependabot-pin-logic.ts +0 -135
  253. package/scripts/test/classify-isolation.ts +0 -149
  254. package/scripts/test/http-fault-injection.ts +0 -79
  255. package/scripts/test/josh-harness-environment.ts +0 -260
  256. package/scripts/test/josh-harness.ts +0 -96
  257. package/scripts/test/pilot-files.ts +0 -452
  258. package/scripts/test/pilot-measure.ts +0 -78
  259. package/scripts/test/test-network-guard.ts +0 -453
  260. package/scripts/test/test-repository-guard.ts +0 -317
  261. package/scripts/test/test-state-guard.ts +0 -85
  262. package/scripts/test/test-stdout-guard.ts +0 -54
  263. package/scripts/test/test-telegram-guard.ts +0 -90
  264. package/scripts/test/unit-guard-environment.ts +0 -12
  265. package/scripts/test/unit-projects.ts +0 -139
  266. package/scripts/test/vitest-include-globs.ts +0 -12
  267. package/scripts/time-runtime/time-batch-guard-fixtures.ts +0 -66
  268. package/scripts-ai/completion-gate.ts +0 -13
  269. package/scripts-ai/environment-loader.ts +0 -9
  270. /package/{scripts-ai → scripts/epic}/epic-cli-argv.ts +0 -0
  271. /package/{scripts-ai → scripts/epic}/epic-cli-remove.ts +0 -0
  272. /package/{scripts-ai → scripts/git}/followup-issue-number.ts +0 -0
@@ -1,109 +0,0 @@
1
- import { mkdirSync, writeFileSync } from 'node:fs'
2
- import path from 'node:path'
3
- import { plan_commands, type CommandRunner, type FormatCommand } from './format-edited-file'
4
-
5
- // Shared across the two `format-edited-file` suites so neither redefines the other's fixtures. The
6
- // per-suite temp directory stays in each test file — vitest isolates the files, so each evaluates
7
- // this module and its own `afterAll` teardown of its own `mkdtemp`.
8
- const PRETTIER = 'prettier'
9
- const ESLINT = 'eslint'
10
-
11
- // What a formatter that ran and had nothing to say returns, so a test runner reads as "this route
12
- // worked" and no fallback is attempted.
13
- const RAN_CLEANLY = { exit_code: 0, stdout: '' }
14
-
15
- function payload_for(file_path: string): string {
16
- return JSON.stringify({
17
- hook_event_name: 'PostToolUse',
18
- tool_input: { file_path },
19
- tool_name: 'Edit',
20
- })
21
- }
22
-
23
- // What Claude Code hands this hook after a shell call, which the matcher covers since
24
- // joshuafolkken/kit#1337: a command, and no edited path anywhere in the payload. The command edits a
25
- // file on purpose — an agent working through `sed` is the mode the widening was measured against,
26
- // and nothing here may start formatting a path it had to guess at.
27
- function shell_payload(transcript_path?: string): string {
28
- return JSON.stringify({
29
- tool_name: 'Bash',
30
- tool_input: { command: `sed -i '' s/a/b/ app.ts` },
31
- transcript_path,
32
- })
33
- }
34
-
35
- function eslint_failing_runner(runs: Array<string>): CommandRunner {
36
- return async (command) => {
37
- await Promise.resolve()
38
-
39
- if (command.bin === ESLINT) throw new Error('spawn ENOENT')
40
-
41
- runs.push(command.bin)
42
-
43
- return RAN_CLEANLY
44
- }
45
- }
46
-
47
- const failing_runner: CommandRunner = async () => {
48
- await Promise.resolve()
49
- throw new Error('the formatter failed to start')
50
- }
51
-
52
- function recording_runner(runs: Array<string>): CommandRunner {
53
- return async (command) => {
54
- runs.push(command.bin)
55
-
56
- await Promise.resolve()
57
-
58
- return RAN_CLEANLY
59
- }
60
- }
61
-
62
- // eslint exits non-zero with its problems on stdout when a `--fix` pass leaves something it could
63
- // not fix; prettier runs cleanly. This is the shape the hook has to lift the diagnostics out of.
64
- function eslint_reporting_runner(stdout: string): CommandRunner {
65
- return async (command) => {
66
- await Promise.resolve()
67
-
68
- if (command.bin === ESLINT) return { exit_code: 1, stdout }
69
-
70
- return RAN_CLEANLY
71
- }
72
- }
73
-
74
- interface DirectoryHelpers {
75
- write_fixture: (...segments: ReadonlyArray<string>) => string
76
- plan_commands_in: (file_path: string) => ReadonlyArray<FormatCommand>
77
- }
78
-
79
- // Bound to a suite's own temp directory so the call sites stay `write_fixture('app.ts')`. The nested
80
- // functions close over `directory`, so they cannot be hoisted to module scope.
81
- function make_directory_helpers(directory: string): DirectoryHelpers {
82
- function write_fixture(...segments: ReadonlyArray<string>): string {
83
- const file_path = path.join(directory, ...segments)
84
-
85
- mkdirSync(path.dirname(file_path), { recursive: true })
86
- writeFileSync(file_path, '\n', 'utf8')
87
-
88
- return file_path
89
- }
90
-
91
- function plan_commands_in(file_path: string): ReadonlyArray<FormatCommand> {
92
- return plan_commands(file_path, directory)
93
- }
94
-
95
- return { write_fixture, plan_commands_in }
96
- }
97
-
98
- export {
99
- eslint_failing_runner,
100
- eslint_reporting_runner,
101
- failing_runner,
102
- make_directory_helpers,
103
- payload_for,
104
- recording_runner,
105
- shell_payload,
106
- ESLINT,
107
- PRETTIER,
108
- RAN_CLEANLY,
109
- }
@@ -1,38 +0,0 @@
1
- import { json_value } from '#scripts/lib/json-value'
2
- import { z } from 'zod'
3
-
4
- // The `UserPromptSubmit` hook commands declared in a `.claude/settings.json`
5
- // (joshuafolkken/kit#1151).
6
- //
7
- // What these commands echo is injected into **every** user turn and then re-read as accumulated
8
- // context on every turn after it, which is why joshuafolkken/kit#967 put a ceiling on their size and
9
- // why `josh cost` names them in the resident breakdown. Two readers, one parser: the suite that
10
- // enforces the ceiling and the report that prices it must agree on what is being measured, or the
11
- // ceiling guards a quantity the report does not show.
12
-
13
- const HOOK_SCHEMA = z.object({ command: z.string().nullish() })
14
- const MATCHER_SCHEMA = z.object({ hooks: z.array(HOOK_SCHEMA).nullish() })
15
- const SETTINGS_SCHEMA = z.object({
16
- hooks: z
17
- .object({
18
- UserPromptSubmit: z.array(MATCHER_SCHEMA).nullish(),
19
- })
20
- .nullish(),
21
- })
22
-
23
- // An unreadable or hook-less settings file yields no commands rather than throwing: a consumer
24
- // project may have neither, and `josh cost` must still print a breakdown there.
25
- function user_prompt_hook_commands(settings_text: string): Array<string> {
26
- const parsed = SETTINGS_SCHEMA.safeParse(json_value.parse_or_undefined(settings_text))
27
- const matchers = parsed.success ? (parsed.data.hooks?.UserPromptSubmit ?? []) : []
28
-
29
- return matchers.flatMap((matcher) =>
30
- (matcher.hooks ?? []).flatMap((hook) =>
31
- typeof hook.command === 'string' ? [hook.command] : [],
32
- ),
33
- )
34
- }
35
-
36
- const prompt_hooks = { user_prompt_hook_commands }
37
-
38
- export { prompt_hooks }
@@ -1,83 +0,0 @@
1
- import { spawnSync } from 'node:child_process'
2
- import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
3
- import { tmpdir } from 'node:os'
4
- import path from 'node:path'
5
- import { git_location_environment } from '#scripts/git/git-location-environment'
6
-
7
- interface HookResult {
8
- status: number | null
9
- stdout: string
10
- stderr: string
11
- }
12
-
13
- interface CheckoutOptions {
14
- git_overrides?: Record<string, string>
15
- is_external_git?: boolean
16
- }
17
-
18
- function create_partial_install(temporary_root: string): void {
19
- const package_root = path.join(temporary_root, 'node_modules/@joshuafolkken/kit')
20
- const hook_path = path.join(package_root, 'dist/hooks/pretool-guard.js')
21
-
22
- mkdirSync(path.dirname(hook_path), { recursive: true })
23
- writeFileSync(path.join(package_root, 'package.json'), '{}')
24
- writeFileSync(hook_path, "process.stdout.write('guard ran')")
25
- }
26
-
27
- function execution_directory(temporary_root: string, is_nested: boolean): string {
28
- if (!is_nested) return temporary_root
29
-
30
- const nested_root = path.join(temporary_root, 'src')
31
-
32
- mkdirSync(nested_root)
33
-
34
- return nested_root
35
- }
36
-
37
- function checkout_environment(temporary_root: string, options: CheckoutOptions): NodeJS.ProcessEnv {
38
- const metadata_root = path.join(temporary_root, 'metadata')
39
- const git_environment = {
40
- ...process.env,
41
- ...git_location_environment.location_free_environment(),
42
- }
43
- const git_arguments = options.is_external_git
44
- ? ['init', '--bare', '-q', metadata_root]
45
- : ['init', '-q']
46
-
47
- spawnSync('git', git_arguments, { cwd: temporary_root, env: git_environment })
48
-
49
- if (options.is_external_git) {
50
- return { ...git_environment, GIT_DIR: metadata_root, GIT_WORK_TREE: temporary_root }
51
- }
52
-
53
- return { ...git_environment, ...options.git_overrides }
54
- }
55
-
56
- function run_in_temporary_checkout(
57
- command: string,
58
- is_partial_install = false,
59
- is_nested = false,
60
- options: CheckoutOptions = {},
61
- ): HookResult {
62
- const temporary_root = mkdtempSync(path.join(tmpdir(), 'kit-hook-bootstrap-'))
63
-
64
- try {
65
- const hook_environment = checkout_environment(temporary_root, options)
66
-
67
- if (is_partial_install) create_partial_install(temporary_root)
68
-
69
- const { status, stdout, stderr } = spawnSync('sh', ['-c', command], {
70
- cwd: execution_directory(temporary_root, is_nested),
71
- encoding: 'utf8',
72
- env: hook_environment,
73
- })
74
-
75
- return { status, stdout, stderr }
76
- } finally {
77
- rmSync(temporary_root, { recursive: true, force: true })
78
- }
79
- }
80
-
81
- const hook_command_bootstrap = { run_in_temporary_checkout }
82
-
83
- export { hook_command_bootstrap }
@@ -1,50 +0,0 @@
1
- /**
2
- * CJK Unified Ideographs range + Hiragana + Katakana + CJK symbols.
3
- * Used to detect non-English issue titles that need translation.
4
- */
5
- const CJK_PATTERN = /[\u{3000}-\u{9FFF}\u{F900}-\u{FAFF}\u{AC00}-\u{D7AF}\u{20000}-\u{2FA1F}]/u
6
-
7
- const MAX_BRANCH_SLUG_LENGTH = 50
8
-
9
- function has_cjk(text: string): boolean {
10
- return CJK_PATTERN.test(text)
11
- }
12
-
13
- function slugify(text: string): string {
14
- const slug = text
15
- .toLowerCase()
16
- .normalize('NFKD')
17
- .replaceAll(/[^a-z0-9]+/gu, '-')
18
- .replaceAll(/-+/gu, '-')
19
- .replaceAll(/(^-)|(-$)/gu, '')
20
-
21
- if (slug.length === 0) return 'update'
22
-
23
- return slug.length > MAX_BRANCH_SLUG_LENGTH
24
- ? slug.slice(0, MAX_BRANCH_SLUG_LENGTH).replace(/-$/u, '')
25
- : slug
26
- }
27
-
28
- function suggest_branch_name(issue_number: number, title: string): string {
29
- return `${String(issue_number)}-${slugify(title)}`
30
- }
31
-
32
- interface IssuePrepResult {
33
- number: number
34
- title: string
35
- is_cjk: boolean
36
- suggested_branch: string
37
- }
38
-
39
- function prepare(issue_number: number, title: string): IssuePrepResult {
40
- return {
41
- number: issue_number,
42
- title,
43
- is_cjk: has_cjk(title),
44
- suggested_branch: suggest_branch_name(issue_number, title),
45
- }
46
- }
47
-
48
- const issue_logic = { has_cjk, slugify, suggest_branch_name, prepare }
49
-
50
- export { issue_logic }