prizmkit 1.1.191 → 1.1.193
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/bundled/VERSION.json +3 -3
- package/bundled/adapters/antigravity/skill-adapter.js +13 -4
- package/bundled/adapters/codex/skill-adapter.js +28 -8
- package/bundled/adapters/cursor/skill-adapter.js +13 -4
- package/bundled/adapters/pi/skill-adapter.js +28 -7
- package/bundled/dev-pipeline/.env.example +4 -12
- package/bundled/dev-pipeline/README.md +28 -44
- package/bundled/dev-pipeline/assets/feature-list-example.json +0 -1
- package/bundled/dev-pipeline/assets/skill-subagent-integration.md +6 -6
- package/bundled/dev-pipeline/prizmkit_runtime/atomic_io.py +48 -0
- package/bundled/dev-pipeline/prizmkit_runtime/checkpoint_state.py +66 -23
- package/bundled/dev-pipeline/prizmkit_runtime/cli.py +10 -7
- package/bundled/dev-pipeline/prizmkit_runtime/commands.py +2 -21
- package/bundled/dev-pipeline/prizmkit_runtime/config.py +48 -78
- package/bundled/dev-pipeline/prizmkit_runtime/daemon.py +127 -67
- package/bundled/dev-pipeline/prizmkit_runtime/gitops.py +158 -462
- package/bundled/dev-pipeline/prizmkit_runtime/heartbeat.py +102 -50
- package/bundled/dev-pipeline/prizmkit_runtime/interoperability.py +1 -25
- package/bundled/dev-pipeline/prizmkit_runtime/paths.py +0 -6
- package/bundled/dev-pipeline/prizmkit_runtime/platform_detection.py +47 -21
- package/bundled/dev-pipeline/prizmkit_runtime/processes.py +217 -156
- package/bundled/dev-pipeline/prizmkit_runtime/reset.py +39 -27
- package/bundled/dev-pipeline/prizmkit_runtime/reset_preserve.py +34 -174
- package/bundled/dev-pipeline/prizmkit_runtime/results.py +25 -0
- package/bundled/dev-pipeline/prizmkit_runtime/runner_bookkeeping.py +133 -110
- package/bundled/dev-pipeline/prizmkit_runtime/runner_classification.py +15 -5
- package/bundled/dev-pipeline/prizmkit_runtime/runner_models.py +1 -95
- package/bundled/dev-pipeline/prizmkit_runtime/runner_prompts.py +0 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runner_status.py +7 -2
- package/bundled/dev-pipeline/prizmkit_runtime/runners.py +540 -262
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_commit.py +175 -135
- package/bundled/dev-pipeline/prizmkit_runtime/runtime_helper.py +90 -9
- package/bundled/dev-pipeline/prizmkit_runtime/sessions.py +214 -133
- package/bundled/dev-pipeline/prizmkit_runtime/status.py +1 -3
- package/bundled/dev-pipeline/prizmkit_runtime/stream_progress.py +2783 -0
- package/bundled/dev-pipeline/prizmkit_runtime/task_checkout.py +27 -102
- package/bundled/dev-pipeline/prizmkit_runtime/test_result.py +58 -4
- package/bundled/dev-pipeline/scripts/check-session-status.py +56 -20
- package/bundled/dev-pipeline/scripts/continuation.py +8 -7
- package/bundled/dev-pipeline/scripts/detect-stuck.py +47 -33
- package/bundled/dev-pipeline/scripts/generate-bootstrap-prompt.py +13 -16
- package/bundled/dev-pipeline/scripts/generate-bugfix-prompt.py +20 -10
- package/bundled/dev-pipeline/scripts/init-bugfix-pipeline.py +10 -7
- package/bundled/dev-pipeline/scripts/init-change-artifact.py +25 -4
- package/bundled/dev-pipeline/scripts/init-pipeline.py +14 -69
- package/bundled/dev-pipeline/scripts/parse-stream-progress.py +31 -2616
- package/bundled/dev-pipeline/scripts/patch-completion-notes.py +4 -24
- package/bundled/dev-pipeline/scripts/prompt_framework.py +85 -20
- package/bundled/dev-pipeline/scripts/status_common.py +591 -0
- package/bundled/dev-pipeline/scripts/update-bug-status.py +85 -463
- package/bundled/dev-pipeline/scripts/update-checkpoint.py +254 -65
- package/bundled/dev-pipeline/scripts/update-feature-status.py +76 -509
- package/bundled/dev-pipeline/scripts/utils.py +5 -12
- package/bundled/dev-pipeline/templates/bootstrap-tier3.md +5 -5
- package/bundled/dev-pipeline/templates/bug-fix-list-schema.json +7 -0
- package/bundled/dev-pipeline/templates/bugfix-bootstrap-prompt.md +7 -7
- package/bundled/dev-pipeline/templates/sections/artifact-manifest.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-manual-verification.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-review.md +1 -1
- package/bundled/dev-pipeline/templates/sections/bugfix-phase-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/checkpoint-system.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-auto.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification-opencli.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-browser-verification.md +2 -2
- package/bundled/dev-pipeline/templates/sections/phase-prizmkit-test.md +2 -1
- package/bundled/dev-pipeline/templates/sections/phase-review-full.md +1 -1
- package/bundled/dev-pipeline/templates/sections/phase-specify-plan-full.md +3 -6
- package/bundled/dev-pipeline/templates/session-status-schema.json +2 -5
- package/bundled/skills/_metadata.json +9 -63
- package/bundled/skills/app-planner/SKILL.md +32 -303
- package/bundled/skills/app-planner/references/app-design-guide.md +0 -4
- package/bundled/skills/app-planner/references/generated-plan-review.md +2 -1
- package/bundled/skills/app-planner/references/project-brief-guide.md +14 -0
- package/bundled/skills/app-planner/references/project-conventions-discovery.md +4 -6
- package/bundled/skills/app-planner/references/project-state-detection.md +2 -3
- package/bundled/skills/bug-fix-workflow/SKILL.md +1 -2
- package/bundled/skills/bug-fix-workflow/references/bug-diagnosis.md +4 -7
- package/bundled/skills/bug-planner/SKILL.md +54 -435
- package/bundled/skills/bug-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/bug-planner/references/input-formats.md +32 -0
- package/bundled/skills/bugfix-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/bugfix-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-pipeline-launcher/SKILL.md +4 -6
- package/bundled/skills/feature-pipeline-launcher/references/configuration.md +4 -28
- package/bundled/skills/feature-planner/SKILL.md +60 -439
- package/bundled/skills/feature-planner/assets/planning-guide.md +1 -1
- package/bundled/skills/feature-planner/references/completeness-review.md +34 -0
- package/bundled/skills/feature-planner/references/decomposition-patterns.md +2 -2
- package/bundled/skills/feature-planner/references/error-recovery.md +1 -1
- package/bundled/skills/feature-planner/references/generated-plan-review.md +3 -2
- package/bundled/skills/feature-planner/references/incremental-feature-planning.md +3 -1
- package/bundled/skills/feature-workflow/SKILL.md +1 -2
- package/bundled/skills/prizmkit/SKILL.md +7 -1
- package/bundled/skills/prizmkit-code-review/SKILL.md +14 -6
- package/bundled/skills/prizmkit-code-review/references/independent-code-review.md +7 -4
- package/bundled/skills/prizmkit-code-review/references/review-report-template.md +16 -0
- package/bundled/skills/prizmkit-code-review/scripts/render_review_report.py +58 -20
- package/bundled/skills/prizmkit-implement/SKILL.md +1 -1
- package/bundled/skills/prizmkit-init/SKILL.md +24 -127
- package/bundled/skills/prizmkit-init/assets/project-brief-template.md +3 -3
- package/bundled/skills/prizmkit-plan/SKILL.md +6 -8
- package/bundled/skills/prizmkit-plan/references/clarify-guide.md +1 -1
- package/bundled/skills/prizmkit-plan/references/independent-plan-review.md +5 -2
- package/bundled/skills/prizmkit-plan/references/review-plan-spec-loop.md +6 -5
- package/bundled/skills/prizmkit-prizm-docs/SKILL.md +1 -13
- package/bundled/skills/prizmkit-prizm-docs/references/op-update.md +1 -1
- package/bundled/skills/prizmkit-retrospective/SKILL.md +6 -4
- package/bundled/skills/prizmkit-test/SKILL.md +25 -133
- package/bundled/skills/prizmkit-test/references/independent-test-review.md +5 -2
- package/bundled/skills/prizmkit-test/references/test-coverage-model.md +6 -0
- package/bundled/skills/prizmkit-workflow/SKILL.md +2 -3
- package/bundled/skills/prizmkit-workflow/references/workflow-state-protocol.md +4 -3
- package/bundled/skills/recovery-workflow/SKILL.md +7 -7
- package/bundled/skills/recovery-workflow/evals/evals.json +1 -1
- package/bundled/skills/recovery-workflow/references/detection.md +1 -3
- package/bundled/skills/recovery-workflow/scripts/detect-recovery-state.py +0 -6
- package/bundled/templates/project-memory-template.md +1 -2
- package/package.json +1 -1
- package/src/scaffold.js +28 -7
- package/bundled/dev-pipeline/SCHEMA_ANALYSIS.md +0 -53
- package/bundled/dev-pipeline/scripts/generate-refactor-prompt.py +0 -649
- package/bundled/dev-pipeline/scripts/init-refactor-pipeline.py +0 -463
- package/bundled/dev-pipeline/scripts/update-refactor-status.py +0 -1512
- package/bundled/dev-pipeline/templates/refactor-bootstrap-prompt.md +0 -240
- package/bundled/dev-pipeline/templates/refactor-list-schema.json +0 -266
- package/bundled/dev-pipeline/templates/sections/refactor-critical-paths.md +0 -15
- package/bundled/dev-pipeline/templates/sections/refactor-mission.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-commit-report.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-phase-implement.md +0 -16
- package/bundled/dev-pipeline/templates/sections/refactor-phase-init.md +0 -9
- package/bundled/dev-pipeline/templates/sections/refactor-phase-plan.md +0 -22
- package/bundled/dev-pipeline/templates/sections/refactor-phase-review.md +0 -19
- package/bundled/dev-pipeline/templates/sections/refactor-phase-test.md +0 -24
- package/bundled/dev-pipeline/templates/sections/refactor-reminders.md +0 -12
- package/bundled/dev-pipeline/templates/sections/refactor-session-context.md +0 -6
- package/bundled/dev-pipeline/templates/sections/refactor-task-contract.md +0 -52
- package/bundled/dev-pipeline/tests/conftest.py +0 -29
- package/bundled/dev-pipeline/tests/live_ai_cli_log_smoke.py +0 -208
- package/bundled/dev-pipeline/tests/test_auto_skip.py +0 -1871
- package/bundled/dev-pipeline/tests/test_checkpoint_state.py +0 -1314
- package/bundled/dev-pipeline/tests/test_generate_bootstrap_prompt.py +0 -1712
- package/bundled/dev-pipeline/tests/test_generate_bugfix_prompt.py +0 -627
- package/bundled/dev-pipeline/tests/test_generate_refactor_prompt.py +0 -478
- package/bundled/dev-pipeline/tests/test_python_runner_parity.py +0 -5641
- package/bundled/dev-pipeline/tests/test_recovery_workflow.py +0 -322
- package/bundled/dev-pipeline/tests/test_repository_bootstrap.py +0 -252
- package/bundled/dev-pipeline/tests/test_reset_modes.py +0 -1208
- package/bundled/dev-pipeline/tests/test_reset_preserve.py +0 -957
- package/bundled/dev-pipeline/tests/test_runtime_commit.py +0 -1113
- package/bundled/dev-pipeline/tests/test_runtime_helper.py +0 -303
- package/bundled/dev-pipeline/tests/test_unified_cli.py +0 -5504
- package/bundled/dev-pipeline/tests/test_utils.py +0 -170
- package/bundled/skills/feature-planner/assets/evaluation-guide.md +0 -44
- package/bundled/skills/refactor-pipeline-launcher/SKILL.md +0 -219
- package/bundled/skills/refactor-pipeline-launcher/references/configuration.md +0 -78
- package/bundled/skills/refactor-planner/SKILL.md +0 -467
- package/bundled/skills/refactor-planner/assets/planning-guide.md +0 -291
- package/bundled/skills/refactor-planner/references/behavior-preservation.md +0 -187
- package/bundled/skills/refactor-planner/references/error-recovery.md +0 -45
- package/bundled/skills/refactor-planner/references/fast-path.md +0 -59
- package/bundled/skills/refactor-planner/references/generated-plan-review.md +0 -107
- package/bundled/skills/refactor-planner/references/planning-phases.md +0 -172
- package/bundled/skills/refactor-planner/references/refactor-scoping-guide.md +0 -230
- package/bundled/skills/refactor-planner/scripts/validate-and-generate-refactor.py +0 -1120
- package/bundled/skills/refactor-workflow/SKILL.md +0 -205
package/bundled/VERSION.json
CHANGED
|
@@ -6,7 +6,10 @@ function applyAntigravityInteractionCompatibility(content) {
|
|
|
6
6
|
const fallback =
|
|
7
7
|
"Use Antigravity's `ask_question` tool when it is available. If it is unavailable in the current surface, ask the same question directly in chat and wait for explicit user input. Tool unavailability is not permission to choose defaults.";
|
|
8
8
|
return content
|
|
9
|
-
.replace(
|
|
9
|
+
.replace(
|
|
10
|
+
/Use `AskUserQuestion`; do not render path options as plain text\./g,
|
|
11
|
+
fallback,
|
|
12
|
+
)
|
|
10
13
|
.replace(
|
|
11
14
|
/Do NOT render options as plain text — the user must be able to click\/select\./g,
|
|
12
15
|
fallback,
|
|
@@ -14,15 +17,21 @@ function applyAntigravityInteractionCompatibility(content) {
|
|
|
14
17
|
.replace(
|
|
15
18
|
/Do NOT render options as plain text \(e\.g\., `\[A\] option \[B\] option`\) — the user must be able to click\/select, not type a letter\./g,
|
|
16
19
|
fallback,
|
|
17
|
-
)
|
|
20
|
+
)
|
|
21
|
+
.replace(/`AskUserQuestion`/g, "Antigravity's `ask_question` tool")
|
|
22
|
+
.replace(/\bAskUserQuestion\b/g, "Antigravity's `ask_question` tool");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function convertSkillReference(content, skillName) {
|
|
26
|
+
return applyAntigravityInteractionCompatibility(content)
|
|
27
|
+
.replace(/\$\{SKILL_DIR\}/g, `${SKILLS_DIR}/${skillName}`);
|
|
18
28
|
}
|
|
19
29
|
|
|
20
30
|
export function convertSkill(skillContent, skillName) {
|
|
21
31
|
const { frontmatter, body } = parseFrontmatter(skillContent);
|
|
22
32
|
if (!frontmatter.name) frontmatter.name = skillName;
|
|
23
33
|
|
|
24
|
-
const convertedBody =
|
|
25
|
-
.replace(/\$\{SKILL_DIR\}/g, `${SKILLS_DIR}/${skillName}`);
|
|
34
|
+
const convertedBody = convertSkillReference(body, skillName);
|
|
26
35
|
const note = `> Antigravity project install: Antigravity discovers this Skill from \`${SKILLS_DIR}/${skillName}/SKILL.md\`. Invoke it as \`/${skillName}\` when manual invocation is needed.\n>\n> Antigravity interaction compatibility: use Antigravity's \`ask_question\` tool when available. If the current surface does not expose it, ask the same required question directly in chat and wait for explicit user input. Tool unavailability is not permission to choose defaults. Only true headless runs with no conversational user may use documented conservative defaults.\n\n`;
|
|
27
36
|
|
|
28
37
|
return buildMarkdown(frontmatter, note + convertedBody);
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { parseFrontmatter, buildMarkdown } from '../shared/frontmatter.js';
|
|
10
10
|
import { SKILL_DEFINITION_FILE } from './paths.js';
|
|
11
11
|
import { existsSync, mkdirSync, cpSync, readdirSync } from 'node:fs';
|
|
12
|
-
import { readFile, writeFile } from 'node:fs/promises';
|
|
12
|
+
import { readdir, readFile, writeFile } from 'node:fs/promises';
|
|
13
13
|
import path from 'path';
|
|
14
14
|
|
|
15
15
|
function toCodexSkillReference(commandName) {
|
|
@@ -35,17 +35,13 @@ function applyCodexInteractionCompatibility(content) {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!frontmatter.name) frontmatter.name = skillName;
|
|
42
|
-
|
|
43
|
-
let convertedBody = applyCodexInteractionCompatibility(body).replace(
|
|
38
|
+
export function convertSkillReference(content, skillName) {
|
|
39
|
+
let converted = applyCodexInteractionCompatibility(content).replace(
|
|
44
40
|
/\$\{SKILL_DIR\}/g,
|
|
45
41
|
`.agents/skills/${skillName}`
|
|
46
42
|
);
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
converted = converted.replace(
|
|
49
45
|
/prizmkit\.(\w+)/g,
|
|
50
46
|
(_match, sub) => {
|
|
51
47
|
const commandName = `prizmkit-${sub.replace(/_/g, '-')}`;
|
|
@@ -53,11 +49,34 @@ export function convertSkill(skillContent, skillName) {
|
|
|
53
49
|
}
|
|
54
50
|
);
|
|
55
51
|
|
|
52
|
+
return converted;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function convertSkill(skillContent, skillName) {
|
|
56
|
+
const { frontmatter, body } = parseFrontmatter(skillContent);
|
|
57
|
+
|
|
58
|
+
if (!frontmatter.name) frontmatter.name = skillName;
|
|
59
|
+
|
|
60
|
+
const convertedBody = convertSkillReference(body, skillName);
|
|
61
|
+
|
|
56
62
|
const codexNote = `> Codex project install: an explicitly named PrizmKit Skill resolves to the same command name under \`.agents/skills/<command-name>/SKILL.md\`.\n>\n> Codex interaction compatibility: when this skill or any referenced PrizmKit file says \`AskUserQuestion\`, use Codex \`request_user_input\` if it is available. If the current Codex surface does not expose \`request_user_input\`, including Default mode, ask the same question directly in chat and wait for explicit user input. Tool unavailability is not permission to choose defaults. If a source instruction asks more questions than Codex allows in one call, split them into multiple calls while preserving order. Only true headless/non-interactive runs, such as \`codex exec\` automation with no conversational user available, may skip interaction and choose documented defaults; never silently choose defaults in an interactive session.\n\n`;
|
|
57
63
|
|
|
58
64
|
return buildMarkdown(frontmatter, codexNote + convertedBody);
|
|
59
65
|
}
|
|
60
66
|
|
|
67
|
+
async function convertReferenceMarkdownDir(dirPath, skillName) {
|
|
68
|
+
if (!existsSync(dirPath)) return;
|
|
69
|
+
for (const entry of await readdir(dirPath, { withFileTypes: true })) {
|
|
70
|
+
const entryPath = path.join(dirPath, entry.name);
|
|
71
|
+
if (entry.isDirectory()) {
|
|
72
|
+
await convertReferenceMarkdownDir(entryPath, skillName);
|
|
73
|
+
} else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
74
|
+
const raw = await readFile(entryPath, 'utf8');
|
|
75
|
+
await writeFile(entryPath, convertSkillReference(raw, skillName), 'utf8');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
61
80
|
export async function installSkill(corePath, targetRoot) {
|
|
62
81
|
const skillName = path.basename(corePath);
|
|
63
82
|
const targetDir = path.join(targetRoot, '.agents', 'skills', skillName);
|
|
@@ -80,5 +99,6 @@ export async function installSkill(corePath, targetRoot) {
|
|
|
80
99
|
);
|
|
81
100
|
}
|
|
82
101
|
}
|
|
102
|
+
await convertReferenceMarkdownDir(path.join(targetDir, 'references'), skillName);
|
|
83
103
|
}
|
|
84
104
|
}
|
|
@@ -4,7 +4,10 @@ import { parseFrontmatter, buildMarkdown } from '../shared/frontmatter.js';
|
|
|
4
4
|
function applyCursorInteractionCompatibility(content) {
|
|
5
5
|
const fallback = 'Use Cursor\'s Ask Questions capability when it is available. If it is unavailable in the current surface, ask the same question directly in chat and wait for explicit user input. Tool unavailability is not permission to choose defaults.';
|
|
6
6
|
return content
|
|
7
|
-
.replace(
|
|
7
|
+
.replace(
|
|
8
|
+
/Use `AskUserQuestion`; do not render path options as plain text\./g,
|
|
9
|
+
fallback,
|
|
10
|
+
)
|
|
8
11
|
.replace(
|
|
9
12
|
/Do NOT render options as plain text — the user must be able to click\/select\./g,
|
|
10
13
|
fallback,
|
|
@@ -12,15 +15,21 @@ function applyCursorInteractionCompatibility(content) {
|
|
|
12
15
|
.replace(
|
|
13
16
|
/Do NOT render options as plain text \(e\.g\., `\[A\] option \[B\] option`\) — the user must be able to click\/select, not type a letter\./g,
|
|
14
17
|
fallback,
|
|
15
|
-
)
|
|
18
|
+
)
|
|
19
|
+
.replace(/`AskUserQuestion`/g, "Cursor's Ask Questions capability")
|
|
20
|
+
.replace(/\bAskUserQuestion\b/g, "Cursor's Ask Questions capability");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function convertSkillReference(content, skillName) {
|
|
24
|
+
return applyCursorInteractionCompatibility(content)
|
|
25
|
+
.replace(/\$\{SKILL_DIR\}/g, `.cursor/skills/${skillName}`);
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
export function convertSkill(skillContent, skillName) {
|
|
19
29
|
const { frontmatter, body } = parseFrontmatter(skillContent);
|
|
20
30
|
if (!frontmatter.name) frontmatter.name = skillName;
|
|
21
31
|
|
|
22
|
-
const convertedBody =
|
|
23
|
-
.replace(/\$\{SKILL_DIR\}/g, `.cursor/skills/${skillName}`);
|
|
32
|
+
const convertedBody = convertSkillReference(body, skillName);
|
|
24
33
|
const note = `> Cursor project install: Cursor discovers this Agent Skill from \`.cursor/skills/${skillName}/SKILL.md\`. Invoke it as \`/${skillName}\` when manual invocation is needed.\n>\n> Cursor interaction compatibility: use Cursor's Ask Questions capability when available. If the current Cursor surface does not expose it, ask the same required question directly in chat and wait for explicit user input. Tool unavailability is not permission to choose defaults. Only true headless runs with no conversational user may use documented conservative defaults.\n\n`;
|
|
25
34
|
|
|
26
35
|
return buildMarkdown(frontmatter, note + convertedBody);
|
|
@@ -2,18 +2,39 @@
|
|
|
2
2
|
import { parseFrontmatter, buildMarkdown } from '../shared/frontmatter.js';
|
|
3
3
|
|
|
4
4
|
function applyPiInteractionCompatibility(content) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const chatFallback =
|
|
6
|
+
'Ask the same options directly in chat and wait for an explicit answer. Do not choose defaults silently.';
|
|
7
|
+
return content
|
|
8
|
+
.replace(
|
|
9
|
+
/Use `AskUserQuestion`; do not render path options as plain text\./g,
|
|
10
|
+
chatFallback,
|
|
11
|
+
)
|
|
12
|
+
.replace(
|
|
13
|
+
/Do NOT render options as plain text[^\n]*\./g,
|
|
14
|
+
chatFallback,
|
|
15
|
+
)
|
|
16
|
+
.replace(/clickable options, never plain text; /g, 'explicit choices in chat; ')
|
|
17
|
+
.replace(/\(never plain text; /g, '(wait for explicit choice in chat; ')
|
|
18
|
+
.replace(
|
|
19
|
+
/`AskUserQuestion`/g,
|
|
20
|
+
'ask the same question directly in chat and wait for explicit user input',
|
|
21
|
+
)
|
|
22
|
+
.replace(
|
|
23
|
+
/\bAskUserQuestion\b/g,
|
|
24
|
+
'ask the same question directly in chat and wait for explicit user input',
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function convertSkillReference(content, skillName) {
|
|
29
|
+
return applyPiInteractionCompatibility(content)
|
|
30
|
+
.replace(/\/(prizmkit-[a-z0-9-]+)/g, '/skill:$1')
|
|
31
|
+
.replace(/\$\{SKILL_DIR\}/g, `.pi/skills/${skillName}`);
|
|
9
32
|
}
|
|
10
33
|
|
|
11
34
|
export function convertSkill(skillContent, skillName) {
|
|
12
35
|
const { frontmatter, body } = parseFrontmatter(skillContent);
|
|
13
36
|
if (!frontmatter.name) frontmatter.name = skillName;
|
|
14
|
-
const convertedBody =
|
|
15
|
-
.replace(/\/(prizmkit-[a-z0-9-]+)/g, '/skill:$1')
|
|
16
|
-
.replace(/\$\{SKILL_DIR\}/g, `.pi/skills/${skillName}`);
|
|
37
|
+
const convertedBody = convertSkillReference(body, skillName);
|
|
17
38
|
const note = `> Pi project install: invoke this skill with \`/skill:${skillName}\`. An explicitly named PrizmKit Skill uses \`/skill:<same-name>\` and its project definition at \`.pi/skills/<same-name>/SKILL.md\`.\n>\n> Pi interaction compatibility: in interactive sessions, ask required questions directly in chat and wait for explicit user input. Only true headless runs may use documented conservative defaults.\n\n`;
|
|
18
39
|
return buildMarkdown(frontmatter, note + convertedBody);
|
|
19
40
|
}
|
|
@@ -11,23 +11,18 @@
|
|
|
11
11
|
#
|
|
12
12
|
# If .prizmkit/.env does not exist, all defaults apply — no error is raised.
|
|
13
13
|
|
|
14
|
-
# ─── Runtime Environment ──────────────────────────────────────────────
|
|
15
|
-
# PRIZMKIT_ENV=test # "test" = output bootstrap prompts to console for debugging
|
|
16
|
-
# Unset or any other value = normal production mode
|
|
17
|
-
|
|
18
14
|
# ─── AI CLI ───────────────────────────────────────────────────────────
|
|
19
15
|
# AI_CLI=claude # AI CLI command. If unset, PrizmKit prefers the installed
|
|
20
|
-
# project platform, then PATH fallback: claude > cbc > codex
|
|
16
|
+
# project platform, then PATH fallback: claude > cbc > codex > pi > agent > agy
|
|
21
17
|
# MODEL= # AI model override (e.g. claude-sonnet-4-20250514)
|
|
22
18
|
# Per-task model in *-list.json overrides this
|
|
19
|
+
# PRIZMKIT_EFFORT= # Reasoning effort override (platform-specific)
|
|
23
20
|
|
|
24
21
|
# ─── Pipeline Execution ──────────────────────────────────────────────
|
|
25
22
|
# MAX_RETRIES=3 # Max retry attempts per task before marking failed
|
|
23
|
+
# STOP_ON_FAILURE=0 # Stop pipeline immediately on first failed task (1=on, 0=continue)
|
|
26
24
|
# VERBOSE=1 # Verbose logging (1=on, 0=off)
|
|
27
25
|
|
|
28
|
-
# ─── Refactor Pipeline Only ──────────────────────────────────────────
|
|
29
|
-
# STRICT_BEHAVIOR_CHECK=1 # Enable strict behavior-preservation gates for refactor tasks (1=on, 0=off)
|
|
30
|
-
|
|
31
26
|
# ─── Branch Management ────────────────────────────────────────────────
|
|
32
27
|
# AUTO_PUSH=0 # Auto-push to remote after successful task (0=off, 1=on)
|
|
33
28
|
# DEV_BRANCH= # Custom dev branch name (default: auto-generated per task)
|
|
@@ -35,7 +30,4 @@
|
|
|
35
30
|
# ─── Logging & Heartbeat ─────────────────────────────────────────────
|
|
36
31
|
# HEARTBEAT_INTERVAL=30 # Heartbeat log interval in seconds
|
|
37
32
|
# HEARTBEAT_STALE_THRESHOLD=600 # Max seconds without heartbeat before marking stale
|
|
38
|
-
# STALE_KILL_THRESHOLD=
|
|
39
|
-
# CODEX_WAIT_STALE_KILL_THRESHOLD=3600 # Longer no-log window while Codex waits on subagents
|
|
40
|
-
# CODEX_SUBAGENT_TIMEOUT_SECONDS=3300 # Codex subagent max runtime; defaults to wait threshold - 300
|
|
41
|
-
# CB_SUBAGENT_STALE_KILL_THRESHOLD=3600 # Longer no-log window while CodeBuddy sub-agents are running
|
|
33
|
+
# STALE_KILL_THRESHOLD=600 # Auto-kill after N seconds without parent log progress (0 = disabled)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dev-pipeline
|
|
2
2
|
|
|
3
|
-
Autonomous development pipeline that drives iterative AI CLI sessions through PrizmKit skills, implementing feature
|
|
3
|
+
Autonomous development pipeline that drives iterative AI CLI sessions through PrizmKit skills, implementing feature and bugfix work from `.prizmkit/plans/*.json` specifications.
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
|
@@ -16,7 +16,7 @@ Autonomous development pipeline that drives iterative AI CLI sessions through Pr
|
|
|
16
16
|
|
|
17
17
|
- Python 3.10+ for the canonical Python CLI under `dev-pipeline/cli.py`
|
|
18
18
|
- No third-party Python runtime packages are required
|
|
19
|
-
- The Python runtime is the sole
|
|
19
|
+
- The Python runtime under `dev-pipeline/` is the sole runtime implementation
|
|
20
20
|
|
|
21
21
|
Inspect the operation-first command surface without dispatching runtime behavior:
|
|
22
22
|
|
|
@@ -111,10 +111,10 @@ python3 ./cli.py reset <family> --failed --preserve-runtime [list-path]
|
|
|
111
111
|
|
|
112
112
|
| Mode | Selector and effect |
|
|
113
113
|
|------|---------------------|
|
|
114
|
-
| `--state-only` | Requires one ID or explicit `--all`. Resets supported blocking roots and only causal `auto_skipped` descendants whose full blocker set is recovered; preserves checkout identity, branches
|
|
114
|
+
| `--state-only` | Requires one ID or explicit `--all`. Resets supported blocking roots and only causal `auto_skipped` descendants whose full blocker set is recovered; preserves checkout identity, branches, source changes, checkpoints, and artifact/session files. Feature roots are `failed` or `skipped`; Bugfix additionally supports `needs_info`. |
|
|
115
115
|
| `--fresh-checkout` | Requires one ID, range, or supported status filter. Performs the former standard reset, may discard active-checkout WIP, and publishes a new checkout boundary without deleting the task branch. |
|
|
116
116
|
| `--clean` | Accepts the fresh-checkout selectors and additionally deletes task branches, session history, continuation summaries, and task artifacts. |
|
|
117
|
-
| `--failed --preserve-runtime` | Whole-list failed-only recovery. Retains runtime history, valid checkout identity, branches
|
|
117
|
+
| `--failed --preserve-runtime` | Whole-list failed-only recovery. Retains runtime history, valid checkout identity, branches, checkpoints, artifacts, and WIP; a missing recorded branch is replaced from its local base and implementation-and-later checkpoints are rewound. |
|
|
118
118
|
|
|
119
119
|
State-only rejects ranges and status filters. Preserve-runtime rejects IDs, ranges, `--all`, clean, other modes, and other filters. Missing modes, conflicting modes, unsupported selectors, and malformed causal dependency state fail before mutation.
|
|
120
120
|
|
|
@@ -129,10 +129,6 @@ python3 ./.prizmkit/dev-pipeline/cli.py run feature F-007
|
|
|
129
129
|
python3 ./.prizmkit/dev-pipeline/cli.py reset bugfix --state-only --all
|
|
130
130
|
python3 ./.prizmkit/dev-pipeline/cli.py run bugfix .prizmkit/plans/bug-fix-list.json
|
|
131
131
|
|
|
132
|
-
# Preserve all failed runtime chains
|
|
133
|
-
python3 ./.prizmkit/dev-pipeline/cli.py reset refactor --failed --preserve-runtime
|
|
134
|
-
python3 ./.prizmkit/dev-pipeline/cli.py run refactor .prizmkit/plans/refactor-list.json
|
|
135
|
-
|
|
136
132
|
# Publish a fresh checkout boundary
|
|
137
133
|
python3 ./.prizmkit/dev-pipeline/cli.py reset feature F-007 --fresh-checkout
|
|
138
134
|
python3 ./.prizmkit/dev-pipeline/cli.py run feature F-007
|
|
@@ -506,33 +502,22 @@ Imported by all Python scripts. Provides:
|
|
|
506
502
|
|
|
507
503
|
## Python Runtime Modules
|
|
508
504
|
|
|
509
|
-
### `prizmkit_runtime/config.py` — CLI
|
|
510
|
-
|
|
511
|
-
Sourced by daemon and runner scripts. Provides:
|
|
505
|
+
### `prizmkit_runtime/config.py` — AI CLI & Environment Resolution
|
|
512
506
|
|
|
513
|
-
|
|
514
|
-
|----------|-------------|
|
|
515
|
-
| `prizm_detect_cli_and_platform()` | Sets `CLI_CMD` and `PLATFORM`. Priority: `AI_CLI` env > `config.json` `ai_cli` > manifest/config platform > `CODEBUDDY_CLI` > installed PrizmKit artifacts > PATH |
|
|
516
|
-
| `prizm_check_common_dependencies(cli_cmd)` | Verifies jq, python3, and CLI are installed |
|
|
507
|
+
Provides `load_runtime_config()`, `load_env_file()`, and `resolve_ai_client()`. Precedence: `AI_CLI` env > `config.json` `ai_cli` > manifest/config platform (`manifest:platform` > `config:platform`) > `CODEBUDDY_CLI` > installed PrizmKit artifacts > `PATH`. `load_env_file()` ignores `#` comment suffixes only outside quotes and stores normalized `effort` from `validate_effort()`.
|
|
517
508
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
### `prizmkit_runtime/gitops.py` — Git Branch Lifecycle
|
|
509
|
+
### `prizmkit_runtime/gitops.py` — Git Repository & Branch Lifecycle
|
|
521
510
|
|
|
522
511
|
| Function | Description |
|
|
523
512
|
|----------|-------------|
|
|
524
|
-
| `
|
|
525
|
-
| `
|
|
513
|
+
| `ensure_git_repository(project_root)` / `ensure_branch_has_commit(project_root)` | Initialize Git automatically when invoked outside a repository and create an initial commit with fallback Git identity when needed |
|
|
514
|
+
| `safe_task_branch_prefix(project_root, nominal)` | Avoid Git D/F ref collisions when an existing branch equals or shares a prefix with the nominal task prefix |
|
|
515
|
+
| `branch_create_plan(context)` / `branch_ensure_return(project_root, base, task)` | Create/reuse task branch cleanly and return to the original non-task `base_branch` without hardcoding `main` |
|
|
516
|
+
| `branch_merge_plan(context, ...)` | Fast-forward or rebase + merge task branch back into `base_branch` with fallback Git identity injected for commit/rebase/merge |
|
|
526
517
|
|
|
527
|
-
### `prizmkit_runtime/heartbeat.py` —
|
|
518
|
+
### `prizmkit_runtime/heartbeat.py` & `sessions.py` — Session I/O & Heartbeat Monitoring
|
|
528
519
|
|
|
529
|
-
|
|
530
|
-
|----------|-------------|
|
|
531
|
-
| `start_heartbeat(cli_pid, session_log, progress_json, interval)` | Start background heartbeat monitor. Sets `_HEARTBEAT_PID`. |
|
|
532
|
-
| `stop_heartbeat(heartbeat_pid)` | Kill heartbeat process |
|
|
533
|
-
| `start_progress_parser(session_log, progress_json, scripts_dir)` | Spawn `parse-stream-progress.py` if stream-json supported. Sets `_PARSER_PID`. |
|
|
534
|
-
| `stop_progress_parser(parser_pid)` | Kill parser process |
|
|
535
|
-
| `detect_stream_json_support(cli_cmd)` | Sets `USE_STREAM_JSON=true\|false` |
|
|
520
|
+
`AISessionLauncher` starts the log reader thread and `HeartbeatMonitor` (which initializes `logs/heartbeat.json` with valid JSON atomically) before streaming prompt text on a daemon `stdin` writer thread, and terminates child process trees cleanly on interruption or launcher errors. `detect_stream_json_support(cli_cmd, platform)` verifies provider `stream-json` capabilities before mutating repository state.
|
|
536
521
|
|
|
537
522
|
---
|
|
538
523
|
|
|
@@ -884,7 +869,7 @@ cli.py run bugfix command
|
|
|
884
869
|
|
|
885
870
|
```
|
|
886
871
|
.prizmkit/dev-pipeline/
|
|
887
|
-
+-- cli.py run <family> # Foreground feature/bugfix
|
|
872
|
+
+-- cli.py run <family> # Foreground feature/bugfix runners
|
|
888
873
|
+-- cli.py status <family|all> # Read-only family or aggregate status
|
|
889
874
|
+-- cli.py reset <family> # Explicit state-only/fresh/clean/preserve reset modes
|
|
890
875
|
+-- cli.py daemon <family> # Background daemon lifecycle
|
|
@@ -893,22 +878,26 @@ cli.py run bugfix command
|
|
|
893
878
|
+-- README.md # This file
|
|
894
879
|
+-- .gitignore # Ignores .prizmkit/state/, __pycache__/
|
|
895
880
|
|
|
|
896
|
-
+--
|
|
897
|
-
| +--
|
|
898
|
-
| +--
|
|
899
|
-
| +--
|
|
881
|
+
+-- prizmkit_runtime/ # Canonical Python runtime modules
|
|
882
|
+
| +-- gitops.py # Repo auto-init, fallback Git identity, branch create/return/merge
|
|
883
|
+
| +-- runners.py # Foreground sequential execution loop
|
|
884
|
+
| +-- runtime_commit.py # Request validation, commit finalization, state/metadata exclusions
|
|
885
|
+
| +-- reset.py / reset_preserve.py # Explicit state-only, fresh-checkout, clean, and preserve-runtime recovery
|
|
886
|
+
| +-- sessions.py / heartbeat.py # Subprocess launch, stdin writer, reader, JSON heartbeat monitor
|
|
887
|
+
| +-- daemon.py / processes.py # Background daemon lifecycle & cross-platform PID/tree cleanup
|
|
900
888
|
|
|
|
901
889
|
+-- scripts/
|
|
902
|
-
| +-- utils.py # Shared Python utilities (JSON I/O, logging)
|
|
890
|
+
| +-- utils.py # Shared Python utilities (atomic JSON I/O, logging)
|
|
903
891
|
| +-- init-pipeline.py # Validate .prizmkit/plans/feature-list.json + create .prizmkit/state/features/
|
|
904
892
|
| +-- init-bugfix-pipeline.py # Validate .prizmkit/plans/bug-fix-list.json + create .prizmkit/state/bugfix/
|
|
905
|
-
| +-- init-change-artifact.py # Create .prizmkit/specs/{slug}/ directories
|
|
893
|
+
| +-- init-change-artifact.py # Create .prizmkit/specs/{slug}/ directories safely
|
|
906
894
|
| +-- generate-bootstrap-prompt.py # Render feature session prompt from template
|
|
907
895
|
| +-- generate-bugfix-prompt.py # Render bugfix session prompt from template
|
|
908
896
|
| +-- check-session-status.py # Parse session-status.json outcome
|
|
909
|
-
| +-- update-
|
|
910
|
-
| +-- update-
|
|
911
|
-
| +--
|
|
897
|
+
| +-- update-checkpoint.py # Validate and atomically update workflow-checkpoint.json
|
|
898
|
+
| +-- update-feature-status.py # Feature state machine
|
|
899
|
+
| +-- update-bug-status.py # Bug state machine
|
|
900
|
+
| +-- detect-stuck.py # Detect stuck/stale sessions (logs/heartbeat.json & last_seen_epoch)
|
|
912
901
|
| +-- parse-stream-progress.py # Real-time stream-json progress parser
|
|
913
902
|
|
|
|
914
903
|
+-- templates/
|
|
@@ -916,7 +905,6 @@ cli.py run bugfix command
|
|
|
916
905
|
| +-- bootstrap-tier3.md # Explicit custom-template compatibility fixture
|
|
917
906
|
| +-- bootstrap-prompt.md # Minimal explicit compatibility template
|
|
918
907
|
| +-- bugfix-bootstrap-prompt.md # Bugfix explicit compatibility template
|
|
919
|
-
| +-- refactor-bootstrap-prompt.md # Refactor explicit compatibility template
|
|
920
908
|
| +-- feature-list-schema.json # JSON schema for .prizmkit/plans/feature-list.json
|
|
921
909
|
| +-- bug-fix-list-schema.json # JSON schema for .prizmkit/plans/bug-fix-list.json
|
|
922
910
|
| +-- session-status-schema.json # JSON schema for session-status.json
|
|
@@ -925,11 +913,7 @@ cli.py run bugfix command
|
|
|
925
913
|
| +-- feature-list-example.json # Example feature list
|
|
926
914
|
| +-- skill-subagent-integration.md # Pipeline + skill-owned subagent integration docs
|
|
927
915
|
|
|
|
928
|
-
+-- tests/
|
|
929
|
-
| +-- conftest.py # Pytest configuration
|
|
930
|
-
| +-- test_generate_bootstrap_prompt.py # Tests for prompt generation
|
|
931
|
-
| +-- test_generate_bugfix_prompt.py # Tests for bugfix prompt generation
|
|
932
|
-
| +-- test_utils.py # Tests for shared utilities
|
|
916
|
+
+-- tests/ # Repository pytest suite (excluded from installed bundled package)
|
|
933
917
|
|
|
|
934
918
|
+-- .prizmkit/state/features/ # Feature pipeline runtime state (gitignored)
|
|
935
919
|
| +-- pipeline.json
|
|
@@ -117,7 +117,6 @@
|
|
|
117
117
|
"tech_stack": "Next.js 14 + Express.js + PostgreSQL + Prisma ORM",
|
|
118
118
|
"design_system": "shadcn/ui + Tailwind CSS",
|
|
119
119
|
"testing_strategy": "Jest (unit) + Playwright (e2e)",
|
|
120
|
-
"deployment": "Docker + Vercel (frontend) + Railway (backend)",
|
|
121
120
|
"language": "TypeScript"
|
|
122
121
|
}
|
|
123
122
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
4
|
|
|
5
|
-
`dev-pipeline` drives feature
|
|
5
|
+
`dev-pipeline` drives feature and bugfix sessions through the unified Python outer loop. Each iteration starts an AI CLI session with a bootstrap prompt that makes the main session orchestrator responsible for planning, implementation, review, testing, retrospective, and commit.
|
|
6
6
|
|
|
7
7
|
Skill behavior is owned by canonical skills:
|
|
8
8
|
|
|
@@ -48,7 +48,7 @@ The Main Agent captures bounded immutable review input from the active checkout
|
|
|
48
48
|
|
|
49
49
|
Independent review runs only when the host can structurally provide read-only access, no mutation, no arbitrary command execution, no downstream execution, and native resume of the same execution unit. If any capability is unavailable or unproven, the stage records strict downgrade and creates no weak substitute. A fresh Reviewer plus a summary is never continuation.
|
|
50
50
|
|
|
51
|
-
Pipeline
|
|
51
|
+
Pipeline execution runs strictly serially in the active project checkout. Skill-level execution units must not create or enter linked worktrees.
|
|
52
52
|
|
|
53
53
|
## Pipeline Scripts
|
|
54
54
|
|
|
@@ -58,24 +58,24 @@ Located at `.prizmkit/dev-pipeline/scripts/`:
|
|
|
58
58
|
|---|---|
|
|
59
59
|
| `init-pipeline.py` | Initialize feature pipeline state |
|
|
60
60
|
| `init-bugfix-pipeline.py` | Initialize bugfix pipeline state |
|
|
61
|
-
| `init-refactor-pipeline.py` | Initialize refactor pipeline state |
|
|
62
61
|
| `init-change-artifact.py` | Initialize feature change-artifact directories |
|
|
63
62
|
| `generate-bootstrap-prompt.py` | Render feature bootstrap prompt with feature context |
|
|
64
63
|
| `generate-bugfix-prompt.py` | Render bugfix bootstrap prompt with bug context |
|
|
65
|
-
| `generate-refactor-prompt.py` | Render refactor bootstrap prompt with refactor context |
|
|
66
64
|
| `update-feature-status.py` | Update feature status after session |
|
|
67
65
|
| `update-bug-status.py` | Update bug status after session |
|
|
68
|
-
| `update-refactor-status.py` | Update refactor status after session |
|
|
69
66
|
| `check-session-status.py` | Read and validate session-status output |
|
|
70
67
|
| `detect-stuck.py` | Detect stuck or stale pipeline sessions |
|
|
71
68
|
| `parse-stream-progress.py` | Parse AI CLI output stream for progress tracking |
|
|
69
|
+
| `update-checkpoint.py` | Validate and atomically update `workflow-checkpoint.json` steps and semantic state |
|
|
70
|
+
| `patch-completion-notes.py` | Patch completion notes onto plan items |
|
|
71
|
+
| `prizmkit-runtime-helper.py` | Helper CLI for platform/port/process/checkpoint text checks |
|
|
72
72
|
| `utils.py` | Shared utility functions for pipeline scripts |
|
|
73
73
|
|
|
74
74
|
## Session Lifecycle
|
|
75
75
|
|
|
76
76
|
1. Runtime selects the next eligible item from the plan list.
|
|
77
77
|
2. Prompt generator renders a session prompt and checkpoint file.
|
|
78
|
-
3. AI CLI session executes the generated prompt in the active project checkout
|
|
78
|
+
3. AI CLI session executes the generated prompt in the active project checkout.
|
|
79
79
|
4. Session writes status and completion artifacts.
|
|
80
80
|
5. Runtime updates plan-list status and propagates completion notes.
|
|
81
81
|
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""Atomic file write helpers shared across runtime modules and CLI scripts."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import os
|
|
7
|
+
import tempfile
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def write_text_atomic(
|
|
12
|
+
path: Path | str,
|
|
13
|
+
text: str,
|
|
14
|
+
*,
|
|
15
|
+
encoding: str = "utf-8",
|
|
16
|
+
fsync: bool = True,
|
|
17
|
+
) -> None:
|
|
18
|
+
"""Atomically write text via a same-directory temporary file and os.replace."""
|
|
19
|
+
target = Path(path)
|
|
20
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
21
|
+
fd, tmp_name = tempfile.mkstemp(dir=target.parent, prefix=f".{target.name}.", suffix=".tmp")
|
|
22
|
+
try:
|
|
23
|
+
with os.fdopen(fd, "w", encoding=encoding) as handle:
|
|
24
|
+
handle.write(text)
|
|
25
|
+
handle.flush()
|
|
26
|
+
if fsync:
|
|
27
|
+
os.fsync(handle.fileno())
|
|
28
|
+
os.replace(tmp_name, target)
|
|
29
|
+
except Exception:
|
|
30
|
+
try:
|
|
31
|
+
os.unlink(tmp_name)
|
|
32
|
+
except OSError:
|
|
33
|
+
pass
|
|
34
|
+
raise
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def write_json_atomic(
|
|
38
|
+
path: Path | str,
|
|
39
|
+
data: object,
|
|
40
|
+
*,
|
|
41
|
+
indent: int | None = 2,
|
|
42
|
+
sort_keys: bool = False,
|
|
43
|
+
ensure_ascii: bool = False,
|
|
44
|
+
fsync: bool = True,
|
|
45
|
+
) -> None:
|
|
46
|
+
"""Atomically serialize JSON to a file with optional fsync durability."""
|
|
47
|
+
payload = json.dumps(data, indent=indent, sort_keys=sort_keys, ensure_ascii=ensure_ascii) + "\n"
|
|
48
|
+
write_text_atomic(path, payload, fsync=fsync)
|