@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.
- package/.claude/settings.json +1 -5
- package/.claude/skills/dependency-update/SKILL.md +6 -3
- package/.claude/skills/epic-commands/SKILL.md +46 -17
- package/.claude/skills/workflow-commands/SKILL.md +8 -23
- package/.claude/skills/workflow-commands/backlogrun-child.md +4 -2
- package/.claude/skills/workflow-commands/backlogrun.md +3 -12
- package/.claude/skills/workflow-commands/fullrun-steps.md +4 -3
- package/.claude/skills/workflow-commands/fullrun.md +1 -1
- package/.claude/skills/workflow-commands/halfrun.md +2 -1
- package/.claude/skills/workflow-commands/into-target.md +1 -1
- package/.claude/skills/workflow-commands/observation-filing.md +42 -43
- package/.claude/skills/workflow-commands/prerequisite.md +1 -1
- package/.codex/hooks.json +1 -5
- package/.github/workflows/sonar-qube.yml +1 -1
- package/AGENTS.md +4 -25
- package/CLAUDE.md +24 -38
- package/GEMINI.md +4 -24
- package/README.md +22 -58
- package/dist/CLAUDE.md +24 -38
- package/dist/hooks/batch-guard.js +4 -4
- package/dist/hooks/{chunk-WMIR5SNX.js → chunk-D67KVGGY.js} +3 -3
- package/dist/hooks/{chunk-EZLHXKJ6.js → chunk-EIFCAJRB.js} +70 -27
- package/dist/hooks/{chunk-KPZN42RT.js → chunk-GJT4BNVE.js} +3 -3
- package/dist/hooks/{chunk-PAXMLGSS.js → chunk-GLBDBJOK.js} +44 -24
- package/dist/hooks/{chunk-GBJUERYK.js → chunk-HOYJU5RM.js} +1 -1
- package/dist/hooks/{chunk-6PSTVOLH.js → chunk-HU66PWWL.js} +33 -57
- package/dist/hooks/{chunk-A2H5I2VD.js → chunk-KG6PZD72.js} +2 -2
- package/dist/hooks/{chunk-AWTFKKFW.js → chunk-XPLP27WA.js} +3 -8
- package/dist/hooks/{chunk-4GDR2YTV.js → chunk-Y27M6A7X.js} +4 -4
- package/dist/hooks/{chunk-56LGMJJV.js → chunk-ZXNE6NY3.js} +2 -2
- package/dist/hooks/codex-hook-adapter.js +10 -10
- package/dist/hooks/duplicate-read-guard.js +5 -5
- package/dist/hooks/format-edited.js +2 -2
- package/dist/hooks/investigation-guard.js +5 -5
- package/dist/hooks/pretool-guard.js +9 -9
- package/dist/hooks/stop-guard.js +11 -15
- package/dist/josh.js +38 -19
- package/dist/version/index.js +93 -41
- package/eslint/base.js +2 -11
- package/package.json +32 -6
- package/prompts/coding-standards.md +15 -290
- package/prompts/collaboration-workflow/cross-repo-epic.md +2 -51
- package/prompts/collaboration-workflow/epic-audit.md +2 -53
- package/prompts/collaboration-workflow/epic-bundle.md +2 -106
- package/prompts/collaboration-workflow/issue-template.md +4 -4
- package/prompts/collaboration-workflow/operating-rules.md +18 -75
- package/prompts/collaboration-workflow/principles.md +74 -0
- package/prompts/collaboration-workflow/residency.md +54 -14
- package/prompts/collaboration-workflow/rule-delivery.md +1 -11
- package/prompts/collaboration-workflow/upstream-interrupt.md +1 -1
- package/prompts/collaboration-workflow.md +22 -28
- package/scripts/adopt/adopt-logic.ts +2 -2
- package/scripts/adopt/adopt-toolkits.ts +1 -1
- package/scripts/adopt/adopt.ts +2 -2
- package/scripts/agent/agent-event.ts +2 -9
- package/scripts/agent/agent-exit-record.ts +2 -9
- package/scripts/backlog/backlog-budget-cli.ts +2 -6
- package/scripts/backlog/backlog-drive-cli.ts +20 -10
- package/scripts/backlog/backlog-drive.ts +50 -16
- package/scripts/backlog/backlog-offer-cli.ts +6 -5
- package/scripts/backlog/backlog-plan.ts +1 -1
- package/scripts/build/build-bin.ts +2 -1
- package/scripts/build/build-config-merge.ts +2 -1
- package/scripts/build/build-hooks.ts +24 -4
- package/scripts/build/build-managed-marker.ts +2 -1
- package/scripts/build/build-self-sync-guard.ts +2 -1
- package/scripts/build/build-version.ts +2 -1
- package/scripts/cases/cases-logic.ts +2 -6
- package/scripts/ci/pr-classification.ts +13 -11
- package/scripts/cost-runtime/cost-transcript.ts +4 -11
- package/scripts/doctor/doctor-consumer.ts +5 -12
- package/scripts/doctor/doctor-ports.ts +2 -2
- package/scripts/document/document-byte-budget.ts +8 -16
- package/scripts/document/document-section.ts +2 -6
- package/scripts/document/entry-read-budget.ts +1 -1
- package/scripts/{git/git-epic-add-body.ts → epic/epic-add-body.ts} +23 -23
- package/scripts/{git/git-epic-add-plan.ts → epic/epic-add-plan.ts} +23 -26
- package/scripts/{git/git-epic-add.ts → epic/epic-add.ts} +17 -17
- package/scripts/epic/epic-audit-cli.ts +4 -4
- package/scripts/epic/epic-audit-orphans.ts +2 -2
- package/scripts/epic/epic-audit-rationale.ts +1 -1
- package/scripts/epic/epic-audit.ts +1 -1
- package/scripts/{git/git-epic-body.ts → epic/epic-body.ts} +6 -6
- package/scripts/epic/epic-bundle-cli.ts +1 -1
- package/scripts/epic/epic-bundle.ts +2 -2
- package/scripts/epic/epic-candidate-confirm.ts +2 -1
- package/scripts/{git/git-epic-chains.ts → epic/epic-chains.ts} +4 -4
- package/{scripts-ai → scripts/epic}/epic-check.ts +5 -4
- package/{scripts-ai → scripts/epic}/epic-cli.ts +4 -4
- package/scripts/{git/git-epic-close-comment.ts → epic/epic-close-comment.ts} +9 -9
- package/scripts/{git/git-epic-close.ts → epic/epic-close.ts} +23 -19
- package/scripts/epic/epic-cross-repo.ts +21 -38
- package/scripts/{git/git-epic-decision.ts → epic/epic-decision.ts} +12 -14
- package/scripts/epic/epic-fetch.ts +3 -3
- package/scripts/epic/epic-graph.ts +3 -3
- package/scripts/epic/epic-index.ts +2 -2
- package/scripts/epic/epic-issue.ts +1 -1
- package/scripts/epic/epic-next.ts +3 -3
- package/scripts/{git/git-epic-parse.ts → epic/epic-parse.ts} +3 -3
- package/scripts/{git/git-epic-promote.ts → epic/epic-promote.ts} +10 -10
- package/scripts/{git/git-epic-read.ts → epic/epic-read.ts} +9 -9
- package/scripts/{git/git-epic-reconcile.ts → epic/epic-reconcile.ts} +18 -20
- package/scripts/{git/git-epic-reference.ts → epic/epic-reference.ts} +4 -23
- package/scripts/epic/epic-relation-recheck.ts +4 -3
- package/scripts/{git/git-epic-relations.ts → epic/epic-relations.ts} +5 -5
- package/scripts/{git/git-epic-remove-plan.ts → epic/epic-remove-plan.ts} +17 -19
- package/scripts/{git/git-epic-remove.ts → epic/epic-remove.ts} +13 -13
- package/scripts/{git/git-epic-run.ts → epic/epic-run.ts} +27 -27
- package/scripts/{git/git-epic-sections.ts → epic/epic-sections.ts} +6 -6
- package/scripts/{git/git-epic-shape.ts → epic/epic-shape.ts} +7 -7
- package/scripts/{git/git-epic-validate.ts → epic/epic-validate.ts} +13 -13
- package/{scripts-ai → scripts/epic}/epic.ts +17 -16
- package/scripts/gh/fix-gh-packages.ts +2 -1
- package/scripts/gh/gh-spawn.ts +12 -10
- package/scripts/git/constants.ts +1 -1
- package/scripts/git/git-branch.ts +10 -1
- package/scripts/git/git-command.ts +1 -1
- package/scripts/git/git-error.ts +2 -5
- package/{scripts-ai → scripts/git}/git-followup-finish.ts +7 -7
- package/scripts/git/git-followup-flush.ts +74 -48
- package/scripts/git/git-followup-issue-close.ts +2 -2
- package/scripts/git/git-followup-label.ts +1 -1
- package/scripts/git/git-followup-pending.ts +1 -1
- package/{scripts-ai → scripts/git}/git-followup-workflow.ts +23 -11
- package/scripts/git/git-gh-exec.ts +85 -26
- package/scripts/git/git-gh-issue-read.ts +2 -2
- package/scripts/git/git-gh-issue-rest.ts +2 -2
- package/scripts/git/git-gh-issue-write.ts +6 -6
- package/scripts/git/git-gh-pr-read.ts +0 -21
- package/scripts/git/git-gh-pr.ts +2 -23
- package/scripts/git/git-pr-followup-wrapup.ts +2 -6
- package/scripts/git/git-preflight.ts +3 -6
- package/scripts/git/git-staging.ts +21 -9
- package/{scripts-ai → scripts/git}/git-workflow.ts +11 -11
- package/scripts/git/github-issue-url.ts +1 -1
- package/scripts/git/issue-labels.ts +1 -1
- package/scripts/git/issue-reference.ts +19 -0
- package/scripts/git/main-merge.ts +2 -1
- package/scripts/git/main-sync.ts +3 -2
- package/scripts/git/schemas.ts +1 -1
- package/scripts/git/stash-pop-args.ts +7 -13
- package/scripts/git/stash-pop-cli.ts +2 -1
- package/{scripts-ai → scripts/git}/telegram-test-logic.ts +2 -2
- package/{scripts-ai → scripts/git}/telegram-test.ts +7 -7
- package/scripts/hooks/format-rewrite-notice.ts +2 -8
- package/scripts/init/init-ai-copy.ts +23 -14
- package/scripts/init/init.ts +8 -4
- package/scripts/init/start-steps.ts +2 -1
- package/scripts/init/start.ts +2 -1
- package/scripts/issue/issue-comment-cli.ts +2 -1
- package/scripts/issue/issue-file-cli.ts +2 -1
- package/scripts/issue/issue-fold-cli.ts +9 -16
- package/scripts/issue/issue-scout-cli.ts +8 -13
- package/scripts/issue/measure-rerun-cli.ts +7 -6
- package/scripts/josh/josh-commands-ai.ts +2 -2
- package/scripts/josh/josh-commands-backlog.ts +1 -1
- package/scripts/josh/josh-commands-development.ts +1 -1
- package/scripts/josh/josh-commands-workflow.ts +4 -4
- package/scripts/lane/lane-cli.ts +2 -1
- package/scripts/lane/lane-open.ts +3 -2
- package/scripts/lane/lane-registry.ts +3 -6
- package/scripts/lib/cli-flags.ts +20 -2
- package/scripts/lib/error-message.ts +9 -0
- package/scripts/lib/read-file.ts +26 -2
- package/scripts/observations/observation-ledger-home.ts +98 -26
- package/scripts/observations/observation-ledger-migrate.ts +26 -21
- package/scripts/observations/observation-ledger-prepare.ts +10 -20
- package/scripts/observations/observation-ledger.ts +58 -25
- package/scripts/observations/observations-flush-cli.ts +6 -23
- package/scripts/observations/observations-flush-landing.ts +2 -1
- package/scripts/observations/observations-flush.ts +29 -20
- package/scripts/package/package-scout-cli.ts +8 -16
- package/scripts/ports/port-command.ts +2 -1
- package/scripts/propagate/propagate-publish.ts +6 -7
- package/scripts/propagate/propagate-steps.ts +2 -1
- package/scripts/propagate/propagate.ts +3 -2
- package/scripts/refactor/import-graph.ts +2 -6
- package/scripts/registry-migration/migrate.ts +3 -2
- package/scripts/registry-migration/user-npmrc.ts +2 -2
- package/scripts/release/release-cli.ts +2 -1
- package/scripts/repo/repo-setting.ts +10 -8
- package/scripts/review/review-finding-ledger.ts +3 -3
- package/scripts/review/review-findings-cli.ts +4 -11
- package/scripts/review/review-record-cli.ts +14 -11
- package/scripts/review/review-record.ts +6 -16
- package/scripts/rules/decision-oracle.ts +2 -2
- package/scripts/rules/rule-body-guard.ts +2 -2
- package/scripts/rules/rule-value-cache.ts +99 -0
- package/scripts/rules/rule-value-cli.ts +10 -9
- package/scripts/rules/rule-value.ts +1 -1
- package/scripts/run/run-carry-args.ts +2 -6
- package/scripts/run/run-carry-cli.ts +5 -7
- package/scripts/run/run-cut-args.ts +7 -13
- package/scripts/run/run-ending-cli.ts +4 -7
- package/scripts/run/run-event-stream.ts +2 -5
- package/scripts/run/run-liveness-cli.ts +4 -7
- package/scripts/run/run-progress-args.ts +2 -6
- package/scripts/run/run-progress-cli.ts +2 -1
- package/scripts/run/run-tail-cli.ts +3 -3
- package/scripts/run/run-tidy-stashes.ts +7 -14
- package/scripts/run/run-wake-cli.ts +2 -6
- package/scripts/run/run-wake-driver.ts +15 -2
- package/scripts/run/run-wake-session.ts +14 -4
- package/scripts/safe-chain/project-config.ts +3 -6
- package/scripts/security/security-audit-provision.ts +6 -7
- package/scripts/sonar/sonar-hotspots-cli.ts +2 -1
- package/scripts/sync/directory-copy-guard.ts +2 -1
- package/scripts/sync/sync-ai-files.ts +3 -3
- package/scripts/sync/template-source-logic.ts +3 -4
- package/scripts/test/e2e-retry-check.ts +3 -6
- package/scripts/ui/ui-routes-cli.ts +3 -6
- package/scripts/version/bump-version.ts +2 -1
- package/scripts/version/version-remote.ts +18 -27
- package/scripts/version/version-targets.ts +3 -3
- package/.claude/skills/workflow-commands/rule-residency.md +0 -267
- package/evals/scenarios/consult-not-execute.json +0 -20
- package/evals/scenarios/no-implicit-workflow.json +0 -26
- package/evals/scenarios/overrides-both-locations.json +0 -29
- package/evals/scenarios/upstream-interrupt.json +0 -23
- package/evals/scenarios/workflow-skill-loaded.json +0 -16
- package/prompts/agent-lint-protocol.json +0 -79
- package/prompts/agent-rules.md +0 -63
- package/prompts/collaboration-workflow/consultation-vs-execution.md +0 -8
- package/prompts/collaboration-workflow/distributed-docs.md +0 -7
- package/prompts/collaboration-workflow/durable-rules.md +0 -24
- package/prompts/collaboration-workflow/latest-first.md +0 -14
- package/prompts/collaboration-workflow/no-clones.md +0 -11
- package/prompts/collaboration-workflow/simplicity-first.md +0 -9
- package/prompts/collaboration-workflow/single-source-rules.md +0 -13
- package/scripts/build/shim-shell.ts +0 -25
- package/scripts/claude/skill-meta.ts +0 -37
- package/scripts/document/document-scan.ts +0 -108
- package/scripts/document/generate-catalog.ts +0 -69
- package/scripts/document/retired-phrases.ts +0 -143
- package/scripts/document/review-agent-type.ts +0 -46
- package/scripts/document/single-source.ts +0 -73
- package/scripts/git/git-fixture-workspace.ts +0 -88
- package/scripts/hooks/format-edited-file-fixtures.ts +0 -109
- package/scripts/hooks/prompt-hooks.ts +0 -38
- package/scripts/init/hook-command-bootstrap.ts +0 -83
- package/scripts/issue/issue-logic.ts +0 -50
- package/scripts/josh/__snapshots__/josh-command-map.test.ts.snap +0 -1227
- package/scripts/josh/josh-script-reader.ts +0 -11
- package/scripts/package/production-dependency-graph.ts +0 -68
- package/scripts/retrospective/retrospective-cli.ts +0 -97
- package/scripts/retrospective/retrospective.ts +0 -127
- package/scripts/rules/delivered-rules-harness.ts +0 -72
- package/scripts/rules/top-level-scripts-guard.ts +0 -47
- package/scripts/run/run-carry-flush.ts +0 -58
- package/scripts/run/run-transcript.golden.txt +0 -57
- package/scripts/run/run-wake-work.ts +0 -108
- package/scripts/sync/dependabot-pin-logic.ts +0 -135
- package/scripts/test/classify-isolation.ts +0 -149
- package/scripts/test/http-fault-injection.ts +0 -79
- package/scripts/test/josh-harness-environment.ts +0 -260
- package/scripts/test/josh-harness.ts +0 -96
- package/scripts/test/pilot-files.ts +0 -452
- package/scripts/test/pilot-measure.ts +0 -78
- package/scripts/test/test-network-guard.ts +0 -453
- package/scripts/test/test-repository-guard.ts +0 -317
- package/scripts/test/test-state-guard.ts +0 -85
- package/scripts/test/test-stdout-guard.ts +0 -54
- package/scripts/test/test-telegram-guard.ts +0 -90
- package/scripts/test/unit-guard-environment.ts +0 -12
- package/scripts/test/unit-projects.ts +0 -139
- package/scripts/test/vitest-include-globs.ts +0 -12
- package/scripts/time-runtime/time-batch-guard-fixtures.ts +0 -66
- package/scripts-ai/completion-gate.ts +0 -13
- package/scripts-ai/environment-loader.ts +0 -9
- /package/{scripts-ai → scripts/epic}/epic-cli-argv.ts +0 -0
- /package/{scripts-ai → scripts/epic}/epic-cli-remove.ts +0 -0
- /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 }
|