@united-workforce/cli 0.4.0 → 0.6.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/README.md +30 -3
- package/dist/.build-fingerprint +1 -0
- package/dist/__tests__/adapter-json-roundtrip.test.js +16 -6
- package/dist/__tests__/adapter-json-roundtrip.test.js.map +1 -1
- package/dist/__tests__/concurrency.test.d.ts +2 -0
- package/dist/__tests__/concurrency.test.d.ts.map +1 -0
- package/dist/__tests__/concurrency.test.js +196 -0
- package/dist/__tests__/concurrency.test.js.map +1 -0
- package/dist/__tests__/config-text-renderer.test.d.ts +2 -0
- package/dist/__tests__/config-text-renderer.test.d.ts.map +1 -0
- package/dist/__tests__/config-text-renderer.test.js +137 -0
- package/dist/__tests__/config-text-renderer.test.js.map +1 -0
- package/dist/__tests__/e2e-mock-agent.test.js +23 -7
- package/dist/__tests__/e2e-mock-agent.test.js.map +1 -1
- package/dist/__tests__/format-text-default.test.d.ts +2 -0
- package/dist/__tests__/format-text-default.test.d.ts.map +1 -0
- package/dist/__tests__/format-text-default.test.js +43 -0
- package/dist/__tests__/format-text-default.test.js.map +1 -0
- package/dist/__tests__/format-text-registry.test.d.ts +2 -0
- package/dist/__tests__/format-text-registry.test.d.ts.map +1 -0
- package/dist/__tests__/format-text-registry.test.js +158 -0
- package/dist/__tests__/format-text-registry.test.js.map +1 -0
- package/dist/__tests__/issue-180-workflow-ref-removed.test.js +1 -1
- package/dist/__tests__/log-text-renderer.test.d.ts +2 -0
- package/dist/__tests__/log-text-renderer.test.d.ts.map +1 -0
- package/dist/__tests__/log-text-renderer.test.js +265 -0
- package/dist/__tests__/log-text-renderer.test.js.map +1 -0
- package/dist/__tests__/output-mapper-thread-list-startedat.test.d.ts +2 -0
- package/dist/__tests__/output-mapper-thread-list-startedat.test.d.ts.map +1 -0
- package/dist/__tests__/output-mapper-thread-list-startedat.test.js +102 -0
- package/dist/__tests__/output-mapper-thread-list-startedat.test.js.map +1 -0
- package/dist/__tests__/output-mapper-workflow-add.test.d.ts +2 -0
- package/dist/__tests__/output-mapper-workflow-add.test.d.ts.map +1 -0
- package/dist/__tests__/output-mapper-workflow-add.test.js +22 -0
- package/dist/__tests__/output-mapper-workflow-add.test.js.map +1 -0
- package/dist/__tests__/pid-recycling.test.js +9 -7
- package/dist/__tests__/pid-recycling.test.js.map +1 -1
- package/dist/__tests__/prompt.test.js +46 -4
- package/dist/__tests__/prompt.test.js.map +1 -1
- package/dist/__tests__/resolve-head-hash.test.js +8 -0
- package/dist/__tests__/resolve-head-hash.test.js.map +1 -1
- package/dist/__tests__/solve-issue-tea-worktree.test.js +3 -1
- package/dist/__tests__/solve-issue-tea-worktree.test.js.map +1 -1
- package/dist/__tests__/step-ask.test.js +9 -1
- package/dist/__tests__/step-ask.test.js.map +1 -1
- package/dist/__tests__/store-unified-threads.test.js +19 -17
- package/dist/__tests__/store-unified-threads.test.js.map +1 -1
- package/dist/__tests__/thread-agent-failure-suspended.test.d.ts +2 -0
- package/dist/__tests__/thread-agent-failure-suspended.test.d.ts.map +1 -0
- package/dist/__tests__/thread-agent-failure-suspended.test.js +332 -0
- package/dist/__tests__/thread-agent-failure-suspended.test.js.map +1 -0
- package/dist/__tests__/thread-cancel-status.test.js +19 -13
- package/dist/__tests__/thread-cancel-status.test.js.map +1 -1
- package/dist/__tests__/thread-cancel-text-renderer.test.d.ts +2 -0
- package/dist/__tests__/thread-cancel-text-renderer.test.d.ts.map +1 -0
- package/dist/__tests__/thread-cancel-text-renderer.test.js +110 -0
- package/dist/__tests__/thread-cancel-text-renderer.test.js.map +1 -0
- package/dist/__tests__/thread-join.test.d.ts +2 -0
- package/dist/__tests__/thread-join.test.d.ts.map +1 -0
- package/dist/__tests__/thread-join.test.js +77 -0
- package/dist/__tests__/thread-join.test.js.map +1 -0
- package/dist/__tests__/thread-list-filters.test.js +10 -8
- package/dist/__tests__/thread-list-filters.test.js.map +1 -1
- package/dist/__tests__/thread-list-template-ms-date.test.d.ts +2 -0
- package/dist/__tests__/thread-list-template-ms-date.test.d.ts.map +1 -0
- package/dist/__tests__/thread-list-template-ms-date.test.js +102 -0
- package/dist/__tests__/thread-list-template-ms-date.test.js.map +1 -0
- package/dist/__tests__/thread-list-workflow-corrupt.test.d.ts +2 -0
- package/dist/__tests__/thread-list-workflow-corrupt.test.d.ts.map +1 -0
- package/dist/__tests__/thread-list-workflow-corrupt.test.js +157 -0
- package/dist/__tests__/thread-list-workflow-corrupt.test.js.map +1 -0
- package/dist/__tests__/thread-poke.test.js +15 -2
- package/dist/__tests__/thread-poke.test.js.map +1 -1
- package/dist/__tests__/thread-read-xml-tags.test.js +10 -9
- package/dist/__tests__/thread-read-xml-tags.test.js.map +1 -1
- package/dist/__tests__/thread-resume.test.js +11 -1
- package/dist/__tests__/thread-resume.test.js.map +1 -1
- package/dist/__tests__/thread-start-cwd-cli.test.js +15 -3
- package/dist/__tests__/thread-start-cwd-cli.test.js.map +1 -1
- package/dist/__tests__/thread-stop-text-renderer.test.d.ts +2 -0
- package/dist/__tests__/thread-stop-text-renderer.test.d.ts.map +1 -0
- package/dist/__tests__/thread-stop-text-renderer.test.js +148 -0
- package/dist/__tests__/thread-stop-text-renderer.test.js.map +1 -0
- package/dist/__tests__/thread-suspend-step.test.js +5 -2
- package/dist/__tests__/thread-suspend-step.test.js.map +1 -1
- package/dist/__tests__/thread-test-helpers.d.ts +7 -0
- package/dist/__tests__/thread-test-helpers.d.ts.map +1 -1
- package/dist/__tests__/thread-test-helpers.js +13 -0
- package/dist/__tests__/thread-test-helpers.js.map +1 -1
- package/dist/__tests__/thread.test.js +11 -9
- package/dist/__tests__/thread.test.js.map +1 -1
- package/dist/__tests__/validate-semantic.test.js +56 -2
- package/dist/__tests__/validate-semantic.test.js.map +1 -1
- package/dist/__tests__/workflow-list-recursive.test.js +10 -7
- package/dist/__tests__/workflow-list-recursive.test.js.map +1 -1
- package/dist/__tests__/workflow-paths.test.d.ts +2 -0
- package/dist/__tests__/workflow-paths.test.d.ts.map +1 -0
- package/dist/__tests__/workflow-paths.test.js +261 -0
- package/dist/__tests__/workflow-paths.test.js.map +1 -0
- package/dist/__tests__/workflow-resolution.test.js +10 -7
- package/dist/__tests__/workflow-resolution.test.js.map +1 -1
- package/dist/__tests__/workflow-show-resolution.test.js +10 -7
- package/dist/__tests__/workflow-show-resolution.test.js.map +1 -1
- package/dist/__tests__/workflow-validate.test.js +75 -55
- package/dist/__tests__/workflow-validate.test.js.map +1 -1
- package/dist/__tests__/write-envelope.test.d.ts +2 -0
- package/dist/__tests__/write-envelope.test.d.ts.map +1 -0
- package/dist/__tests__/write-envelope.test.js +201 -0
- package/dist/__tests__/write-envelope.test.js.map +1 -0
- package/dist/cli.js +76 -36
- package/dist/cli.js.map +1 -1
- package/dist/commands/config.d.ts +5 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +81 -3
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/prompt.d.ts.map +1 -1
- package/dist/commands/prompt.js +42 -29
- package/dist/commands/prompt.js.map +1 -1
- package/dist/commands/setup.d.ts +9 -4
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +51 -7
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/thread.d.ts +12 -0
- package/dist/commands/thread.d.ts.map +1 -1
- package/dist/commands/thread.js +226 -9
- package/dist/commands/thread.js.map +1 -1
- package/dist/commands/workflow.d.ts +2 -2
- package/dist/commands/workflow.d.ts.map +1 -1
- package/dist/commands/workflow.js +26 -10
- package/dist/commands/workflow.js.map +1 -1
- package/dist/concurrency/concurrency.d.ts +34 -0
- package/dist/concurrency/concurrency.d.ts.map +1 -0
- package/dist/concurrency/concurrency.js +216 -0
- package/dist/concurrency/concurrency.js.map +1 -0
- package/dist/concurrency/index.d.ts +3 -0
- package/dist/concurrency/index.d.ts.map +1 -0
- package/dist/concurrency/index.js +2 -0
- package/dist/concurrency/index.js.map +1 -0
- package/dist/concurrency/types.d.ts +19 -0
- package/dist/concurrency/types.d.ts.map +1 -0
- package/dist/concurrency/types.js +2 -0
- package/dist/concurrency/types.js.map +1 -0
- package/dist/format.d.ts +69 -2
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +198 -1
- package/dist/format.js.map +1 -1
- package/dist/output-mappers.d.ts +122 -0
- package/dist/output-mappers.d.ts.map +1 -0
- package/dist/output-mappers.js +134 -0
- package/dist/output-mappers.js.map +1 -0
- package/dist/schemas.d.ts +4 -1
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +31 -4
- package/dist/schemas.js.map +1 -1
- package/dist/store.d.ts +11 -0
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +20 -1
- package/dist/store.js.map +1 -1
- package/dist/text-renderers.d.ts +30 -0
- package/dist/text-renderers.d.ts.map +1 -0
- package/dist/text-renderers.js +251 -0
- package/dist/text-renderers.js.map +1 -0
- package/dist/validate-semantic.d.ts.map +1 -1
- package/dist/validate-semantic.js +28 -11
- package/dist/validate-semantic.js.map +1 -1
- package/examples/brainstorm.yaml +130 -0
- package/examples/debate.yaml +169 -0
- package/examples/socratic-questioning.yaml +112 -0
- package/package.json +12 -11
- package/src/__tests__/adapter-json-roundtrip.test.ts +15 -6
- package/src/__tests__/concurrency.test.ts +266 -0
- package/src/__tests__/config-text-renderer.test.ts +156 -0
- package/src/__tests__/e2e-mock-agent.test.ts +45 -7
- package/src/__tests__/format-text-default.test.ts +49 -0
- package/src/__tests__/format-text-registry.test.ts +173 -0
- package/src/__tests__/issue-180-workflow-ref-removed.test.ts +1 -1
- package/src/__tests__/log-text-renderer.test.ts +294 -0
- package/src/__tests__/output-mapper-thread-list-startedat.test.ts +124 -0
- package/src/__tests__/output-mapper-workflow-add.test.ts +24 -0
- package/src/__tests__/pid-recycling.test.ts +9 -8
- package/src/__tests__/prompt.test.ts +48 -4
- package/src/__tests__/resolve-head-hash.test.ts +7 -0
- package/src/__tests__/solve-issue-tea-worktree.test.ts +3 -1
- package/src/__tests__/step-ask.test.ts +8 -1
- package/src/__tests__/store-unified-threads.test.ts +21 -18
- package/src/__tests__/thread-agent-failure-suspended.test.ts +406 -0
- package/src/__tests__/thread-cancel-status.test.ts +21 -14
- package/src/__tests__/thread-cancel-text-renderer.test.ts +125 -0
- package/src/__tests__/thread-join.test.ts +103 -0
- package/src/__tests__/thread-list-filters.test.ts +9 -9
- package/src/__tests__/thread-list-template-ms-date.test.ts +110 -0
- package/src/__tests__/thread-list-workflow-corrupt.test.ts +198 -0
- package/src/__tests__/thread-poke.test.ts +14 -2
- package/src/__tests__/thread-read-xml-tags.test.ts +9 -11
- package/src/__tests__/thread-resume.test.ts +10 -1
- package/src/__tests__/thread-start-cwd-cli.test.ts +15 -3
- package/src/__tests__/thread-stop-text-renderer.test.ts +168 -0
- package/src/__tests__/thread-suspend-step.test.ts +5 -2
- package/src/__tests__/thread-test-helpers.ts +15 -1
- package/src/__tests__/thread.test.ts +10 -10
- package/src/__tests__/validate-semantic.test.ts +59 -2
- package/src/__tests__/workflow-list-recursive.test.ts +9 -9
- package/src/__tests__/workflow-paths.test.ts +337 -0
- package/src/__tests__/workflow-resolution.test.ts +9 -8
- package/src/__tests__/workflow-show-resolution.test.ts +9 -8
- package/src/__tests__/workflow-validate.test.ts +78 -56
- package/src/__tests__/write-envelope.test.ts +257 -0
- package/src/cli.ts +111 -35
- package/src/commands/config.ts +85 -3
- package/src/commands/prompt.ts +42 -29
- package/src/commands/setup.ts +57 -7
- package/src/commands/thread.ts +280 -9
- package/src/commands/workflow.ts +32 -11
- package/src/concurrency/concurrency.ts +245 -0
- package/src/concurrency/index.ts +10 -0
- package/src/concurrency/types.ts +19 -0
- package/src/format.ts +282 -2
- package/src/output-mappers.ts +255 -0
- package/src/schemas.ts +39 -3
- package/src/store.ts +25 -1
- package/src/text-renderers.ts +355 -0
- package/src/validate-semantic.ts +33 -12
- package/LICENSE +0 -21
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: debate
|
|
3
|
+
description: "Multi-role structured debate with critical thinking framework and host summary."
|
|
4
|
+
|
|
5
|
+
# Shared frontmatter schema for debater roles (YAML anchor)
|
|
6
|
+
x-debater-frontmatter: &debater-frontmatter
|
|
7
|
+
type: object
|
|
8
|
+
oneOf:
|
|
9
|
+
- properties:
|
|
10
|
+
$status: { const: speak }
|
|
11
|
+
argument: { type: string }
|
|
12
|
+
required: [$status, argument]
|
|
13
|
+
- properties:
|
|
14
|
+
$status: { const: conceded }
|
|
15
|
+
reason: { type: string }
|
|
16
|
+
required: [$status, reason]
|
|
17
|
+
- properties:
|
|
18
|
+
$status: { const: final }
|
|
19
|
+
closing: { type: string }
|
|
20
|
+
required: [$status, closing]
|
|
21
|
+
|
|
22
|
+
roles:
|
|
23
|
+
proponent:
|
|
24
|
+
description: "Argues FOR the proposition"
|
|
25
|
+
goal: "Build a compelling case for the proposition through logical reasoning and evidence"
|
|
26
|
+
capabilities: []
|
|
27
|
+
procedure: |
|
|
28
|
+
You are an experienced scholar arguing FOR the proposition.
|
|
29
|
+
|
|
30
|
+
## Critical Thinking Framework (execute before every speech)
|
|
31
|
+
|
|
32
|
+
### A. Pre-speech reflection (internal, do not output)
|
|
33
|
+
- Does every step in my argument chain hold? Any hidden assumptions or logical gaps?
|
|
34
|
+
- If I were my opponent, how would I attack this? Where am I weakest?
|
|
35
|
+
- Does my evidence actually support my claim, or could it backfire?
|
|
36
|
+
- Should I go on offense or defense this round?
|
|
37
|
+
|
|
38
|
+
### B. Evidence discipline
|
|
39
|
+
- Verify key numbers — watch for order-of-magnitude errors
|
|
40
|
+
- Assess data freshness — fast-moving fields have short half-lives
|
|
41
|
+
- Distinguish primary data from secondary citations, expert opinion, and common assumptions
|
|
42
|
+
|
|
43
|
+
### C. Anti-fragility
|
|
44
|
+
- Anticipate counterarguments; preemptively strengthen or strategically abandon weak points
|
|
45
|
+
- Catch logical gaps, data misuse, or outdated claims in your opponent's reasoning
|
|
46
|
+
|
|
47
|
+
## Rules
|
|
48
|
+
1. Check Thread Progress to see how many times you have spoken.
|
|
49
|
+
2. On your 3rd speech, you MUST output $status: final (closing statement).
|
|
50
|
+
3. If genuinely convinced by the opponent, output $status: conceded.
|
|
51
|
+
4. Otherwise output $status: speak and counter the opponent's points.
|
|
52
|
+
5. Be rigorous, cite evidence, stay concise.
|
|
53
|
+
output: "Debate argument"
|
|
54
|
+
frontmatter: *debater-frontmatter
|
|
55
|
+
|
|
56
|
+
opponent:
|
|
57
|
+
description: "Argues AGAINST the proposition"
|
|
58
|
+
goal: "Build a compelling case against the proposition through logical reasoning and evidence"
|
|
59
|
+
capabilities: []
|
|
60
|
+
procedure: |
|
|
61
|
+
You are an experienced scholar arguing AGAINST the proposition.
|
|
62
|
+
|
|
63
|
+
## Critical Thinking Framework (execute before every speech)
|
|
64
|
+
|
|
65
|
+
### A. Pre-speech reflection (internal, do not output)
|
|
66
|
+
- Does every step in my argument chain hold? Any hidden assumptions or logical gaps?
|
|
67
|
+
- If I were my opponent, how would I attack this? Where am I weakest?
|
|
68
|
+
- Does my evidence actually support my claim, or could it backfire?
|
|
69
|
+
- Should I go on offense or defense this round?
|
|
70
|
+
|
|
71
|
+
### B. Evidence discipline
|
|
72
|
+
- Verify key numbers — watch for order-of-magnitude errors
|
|
73
|
+
- Assess data freshness — fast-moving fields have short half-lives
|
|
74
|
+
- Distinguish primary data from secondary citations, expert opinion, and common assumptions
|
|
75
|
+
|
|
76
|
+
### C. Anti-fragility
|
|
77
|
+
- Anticipate counterarguments; preemptively strengthen or strategically abandon weak points
|
|
78
|
+
- Catch logical gaps, data misuse, or outdated claims in your opponent's reasoning
|
|
79
|
+
|
|
80
|
+
## Rules
|
|
81
|
+
1. Check Thread Progress to see how many times you have spoken.
|
|
82
|
+
2. On your 3rd speech, or when the proponent has issued a final statement, you MUST output $status: final.
|
|
83
|
+
3. If genuinely convinced by the proponent, output $status: conceded.
|
|
84
|
+
4. Otherwise output $status: speak and counter the proponent's points.
|
|
85
|
+
5. Be rigorous, cite evidence, stay concise.
|
|
86
|
+
output: "Debate argument"
|
|
87
|
+
frontmatter: *debater-frontmatter
|
|
88
|
+
|
|
89
|
+
host:
|
|
90
|
+
description: "Debate moderator — delivers impartial summary and verdict"
|
|
91
|
+
goal: "Objectively review the debate, analyze both sides, and deliver a verdict"
|
|
92
|
+
capabilities: []
|
|
93
|
+
procedure: |
|
|
94
|
+
You are an experienced academic debate moderator.
|
|
95
|
+
|
|
96
|
+
## Task
|
|
97
|
+
1. Outline each side's core arguments
|
|
98
|
+
2. Evaluate reasoning quality and evidence use
|
|
99
|
+
3. Highlight the most impactful exchanges
|
|
100
|
+
4. Analyze the deeper significance of the topic
|
|
101
|
+
5. Deliver an overall verdict
|
|
102
|
+
|
|
103
|
+
## Style
|
|
104
|
+
- Impartial but with independent judgment
|
|
105
|
+
- Substantive, not superficial
|
|
106
|
+
output: "Debate summary report"
|
|
107
|
+
frontmatter:
|
|
108
|
+
type: object
|
|
109
|
+
properties:
|
|
110
|
+
$status: { const: done }
|
|
111
|
+
summary: { type: string }
|
|
112
|
+
highlights: { type: string }
|
|
113
|
+
verdict: { type: string }
|
|
114
|
+
required: [$status, summary, highlights, verdict]
|
|
115
|
+
|
|
116
|
+
reporter:
|
|
117
|
+
description: "Generates an HTML report of the completed debate"
|
|
118
|
+
goal: "Produce a self-contained, visually polished HTML report that faithfully reproduces the entire debate with no paraphrasing."
|
|
119
|
+
capabilities: [run_command, write_file, read_file]
|
|
120
|
+
procedure: |
|
|
121
|
+
You are a report generator for a structured debate.
|
|
122
|
+
|
|
123
|
+
## Steps
|
|
124
|
+
1. Read Thread Progress to get the thread ID.
|
|
125
|
+
2. Run: `uwf thread read <thread-id>` to get the full debate transcript.
|
|
126
|
+
3. Design and write a self-contained HTML file that presents the debate beautifully.
|
|
127
|
+
4. Save to `/tmp/debate-report-<thread-id>.html`.
|
|
128
|
+
|
|
129
|
+
## HTML Report Requirements
|
|
130
|
+
- Title: the debate proposition
|
|
131
|
+
- Two-column layout comparing proponent vs opponent arguments round by round
|
|
132
|
+
- Key exchanges highlighted with visual callouts
|
|
133
|
+
- Host's verdict and summary in a prominent section
|
|
134
|
+
- If a side conceded, make it visually clear
|
|
135
|
+
- Clean typography, responsive layout, dark/light theme friendly
|
|
136
|
+
- All content verbatim from `uwf thread read` — do NOT paraphrase
|
|
137
|
+
|
|
138
|
+
## Rules
|
|
139
|
+
1. You MUST use `uwf thread read` to get the data — do NOT rely on context.
|
|
140
|
+
2. Completely self-contained (inline styles, no CDN links).
|
|
141
|
+
3. Output the file path in your response body.
|
|
142
|
+
output: "Confirmation that the report was generated, with the file path."
|
|
143
|
+
frontmatter:
|
|
144
|
+
type: object
|
|
145
|
+
properties:
|
|
146
|
+
$status: { const: done }
|
|
147
|
+
reportPath: { type: string }
|
|
148
|
+
required: [$status, reportPath]
|
|
149
|
+
|
|
150
|
+
graph:
|
|
151
|
+
$START:
|
|
152
|
+
new: { role: proponent, prompt: "The debate begins. You are arguing FOR the proposition. Present your opening argument." }
|
|
153
|
+
resume: { role: proponent, prompt: "The debate continues." }
|
|
154
|
+
|
|
155
|
+
proponent:
|
|
156
|
+
speak: { role: opponent, prompt: "Proponent argues:\n\n{{ argument }}\n\nYou are the opponent. Counter this argument." }
|
|
157
|
+
conceded: { role: host, prompt: "The proponent conceded: {{ reason }}\n\nPlease summarize the debate." }
|
|
158
|
+
final: { role: opponent, prompt: "Proponent's closing statement:\n\n{{ closing }}\n\nYou are the opponent. Deliver your final response." }
|
|
159
|
+
|
|
160
|
+
opponent:
|
|
161
|
+
speak: { role: proponent, prompt: "Opponent argues:\n\n{{ argument }}\n\nYou are the proponent. Counter this argument." }
|
|
162
|
+
conceded: { role: host, prompt: "The opponent conceded: {{ reason }}\n\nPlease summarize the debate." }
|
|
163
|
+
final: { role: host, prompt: "Opponent's closing statement:\n\n{{ closing }}\n\nThe debate is over. Please summarize." }
|
|
164
|
+
|
|
165
|
+
host:
|
|
166
|
+
done: { role: reporter, prompt: "Debate summary complete.\n\nSummary: {{ summary }}\nHighlights: {{ highlights }}\nVerdict: {{ verdict }}\n\nGenerate a polished HTML report of the entire debate." }
|
|
167
|
+
|
|
168
|
+
reporter:
|
|
169
|
+
done: { role: "$END", prompt: "Report generated." }
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
version: 1
|
|
2
|
+
name: socratic-questioning
|
|
3
|
+
description: "Socratic dialogue — a questioner helps the thinker examine their beliefs through probing questions."
|
|
4
|
+
|
|
5
|
+
roles:
|
|
6
|
+
thinker:
|
|
7
|
+
description: "Holds and defends a position, refining it through dialogue"
|
|
8
|
+
goal: "Articulate and examine your position honestly. When a question exposes a weakness, acknowledge it and refine your view rather than deflecting."
|
|
9
|
+
capabilities: []
|
|
10
|
+
procedure: |
|
|
11
|
+
You are a thoughtful person exploring your own beliefs through dialogue.
|
|
12
|
+
|
|
13
|
+
## Rules
|
|
14
|
+
1. Check Thread Progress to see how many times you have responded.
|
|
15
|
+
2. On your 3rd response, you MUST output $status: synthesis (your refined position).
|
|
16
|
+
3. Be honest — if a question reveals a gap, say so and adjust.
|
|
17
|
+
4. Build on previous exchanges, don't repeat yourself.
|
|
18
|
+
5. Keep responses focused (under 300 words).
|
|
19
|
+
output: "Your response to the question, or your final synthesis."
|
|
20
|
+
frontmatter:
|
|
21
|
+
oneOf:
|
|
22
|
+
- properties:
|
|
23
|
+
$status: { const: respond }
|
|
24
|
+
insight: { type: string }
|
|
25
|
+
required: [$status, insight]
|
|
26
|
+
- properties:
|
|
27
|
+
$status: { const: synthesis }
|
|
28
|
+
revisedPosition: { type: string }
|
|
29
|
+
keyInsights: { type: string }
|
|
30
|
+
required: [$status, revisedPosition, keyInsights]
|
|
31
|
+
|
|
32
|
+
questioner:
|
|
33
|
+
description: "Asks probing questions to help the thinker examine assumptions"
|
|
34
|
+
goal: "Guide the thinker to deeper understanding through questions — never lecture, never argue, never assert your own position."
|
|
35
|
+
capabilities: []
|
|
36
|
+
procedure: |
|
|
37
|
+
You are a Socratic questioner. Your only tool is the question.
|
|
38
|
+
|
|
39
|
+
## Questioning techniques
|
|
40
|
+
- **Clarification**: "What do you mean by...?" / "Can you give an example?"
|
|
41
|
+
- **Assumptions**: "What are you assuming here?" / "Why do you believe that's true?"
|
|
42
|
+
- **Evidence**: "What evidence supports this?" / "How would you respond to someone who says...?"
|
|
43
|
+
- **Implications**: "If that's true, what follows?" / "What would change if you're wrong?"
|
|
44
|
+
- **Perspective**: "How might someone in a different situation see this?"
|
|
45
|
+
|
|
46
|
+
## Rules
|
|
47
|
+
1. Ask 1-2 questions per turn, not more.
|
|
48
|
+
2. NEVER state your own opinion or argue a position.
|
|
49
|
+
3. Build on the thinker's previous answer — don't jump to unrelated topics.
|
|
50
|
+
4. When the thinker reaches a synthesis, output $status: done.
|
|
51
|
+
5. Keep questions concise and sharp.
|
|
52
|
+
output: "Your probing question(s)."
|
|
53
|
+
frontmatter:
|
|
54
|
+
oneOf:
|
|
55
|
+
- properties:
|
|
56
|
+
$status: { const: ask }
|
|
57
|
+
question: { type: string }
|
|
58
|
+
required: [$status, question]
|
|
59
|
+
- properties:
|
|
60
|
+
$status: { const: done }
|
|
61
|
+
summary: { type: string }
|
|
62
|
+
required: [$status, summary]
|
|
63
|
+
|
|
64
|
+
reporter:
|
|
65
|
+
description: "Generates an HTML report of the completed Socratic dialogue"
|
|
66
|
+
goal: "Produce a self-contained, visually polished HTML report that faithfully reproduces the entire dialogue with no paraphrasing."
|
|
67
|
+
capabilities: [run_command, write_file, read_file]
|
|
68
|
+
procedure: |
|
|
69
|
+
You are a report generator for a Socratic questioning session.
|
|
70
|
+
|
|
71
|
+
## Steps
|
|
72
|
+
1. Read Thread Progress to get the thread ID.
|
|
73
|
+
2. Run: `uwf thread read <thread-id>` to get the full dialogue transcript.
|
|
74
|
+
3. Design and write a self-contained HTML file that presents the dialogue beautifully.
|
|
75
|
+
4. Save to `/tmp/socratic-report-<thread-id>.html`.
|
|
76
|
+
|
|
77
|
+
## HTML Report Requirements
|
|
78
|
+
- Title: the original topic/position being examined
|
|
79
|
+
- Each exchange as a dialogue card (questioner question → thinker response)
|
|
80
|
+
- Visual distinction between questions and reflections
|
|
81
|
+
- The thinker's initial position and final synthesis prominently displayed
|
|
82
|
+
- A "journey" section showing how the position evolved
|
|
83
|
+
- Clean typography, responsive layout, dark/light theme friendly
|
|
84
|
+
- All content verbatim from `uwf thread read` — do NOT paraphrase
|
|
85
|
+
|
|
86
|
+
## Rules
|
|
87
|
+
1. You MUST use `uwf thread read` to get the data — do NOT rely on context.
|
|
88
|
+
2. Completely self-contained (inline styles, no CDN links).
|
|
89
|
+
3. Output the file path in your response body.
|
|
90
|
+
output: "Confirmation that the report was generated, with the file path."
|
|
91
|
+
frontmatter:
|
|
92
|
+
type: object
|
|
93
|
+
properties:
|
|
94
|
+
$status: { const: done }
|
|
95
|
+
reportPath: { type: string }
|
|
96
|
+
required: [$status, reportPath]
|
|
97
|
+
|
|
98
|
+
graph:
|
|
99
|
+
$START:
|
|
100
|
+
new: { role: thinker, prompt: "State your initial position on the topic. Be clear about what you believe and why." }
|
|
101
|
+
resume: { role: thinker, prompt: "Continue the dialogue from where you left off." }
|
|
102
|
+
|
|
103
|
+
thinker:
|
|
104
|
+
respond: { role: questioner, prompt: "The thinker says:\n\n{{ _body }}\n\nAsk a probing question to help them examine this further." }
|
|
105
|
+
synthesis: { role: questioner, prompt: "The thinker has reached a synthesis:\n\n{{ _body }}\n\nBriefly summarize the journey of this dialogue." }
|
|
106
|
+
|
|
107
|
+
questioner:
|
|
108
|
+
ask: { role: thinker, prompt: "The questioner asks:\n\n{{ _body }}\n\nReflect on this question and respond honestly." }
|
|
109
|
+
done: { role: reporter, prompt: "Dialogue complete.\n\nSummary: {{ summary }}\n\nGenerate a polished HTML report of the entire Socratic dialogue." }
|
|
110
|
+
|
|
111
|
+
reporter:
|
|
112
|
+
done: { role: "$END", prompt: "Report generated." }
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@united-workforce/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"src",
|
|
6
6
|
"dist",
|
|
7
|
+
"examples",
|
|
7
8
|
"package.json"
|
|
8
9
|
],
|
|
9
10
|
"type": "module",
|
|
@@ -13,13 +14,17 @@
|
|
|
13
14
|
"dependencies": {
|
|
14
15
|
"@ocas/core": "^0.5.0",
|
|
15
16
|
"@ocas/fs": "^0.4.1",
|
|
17
|
+
"@united-workforce/protocol": "workspace:^",
|
|
18
|
+
"@united-workforce/util": "workspace:^",
|
|
19
|
+
"@united-workforce/util-agent": "workspace:^",
|
|
16
20
|
"commander": "^14.0.3",
|
|
17
21
|
"dotenv": "^16.6.1",
|
|
18
22
|
"liquidjs": "^10.27.0",
|
|
19
|
-
"yaml": "^2.8.4"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
+
"yaml": "^2.8.4"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"test": "vitest run src/",
|
|
27
|
+
"test:ci": "vitest run src/"
|
|
23
28
|
},
|
|
24
29
|
"publishConfig": {
|
|
25
30
|
"access": "public"
|
|
@@ -34,9 +39,5 @@
|
|
|
34
39
|
"bugs": {
|
|
35
40
|
"url": "https://git.shazhou.work/shazhou/united-workforce/issues"
|
|
36
41
|
},
|
|
37
|
-
"license": "MIT"
|
|
38
|
-
|
|
39
|
-
"test": "vitest run src/",
|
|
40
|
-
"test:ci": "vitest run src/"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
42
|
+
"license": "MIT"
|
|
43
|
+
}
|
|
@@ -25,12 +25,19 @@ const OUTPUT_SCHEMA = {
|
|
|
25
25
|
// ── fixture ──────────────────────────────────────────────────────────────────
|
|
26
26
|
|
|
27
27
|
let tmpDir: string;
|
|
28
|
+
let savedOcasHome: string | undefined;
|
|
28
29
|
|
|
29
30
|
beforeEach(async () => {
|
|
31
|
+
savedOcasHome = process.env.OCAS_HOME;
|
|
30
32
|
tmpDir = await mkdtemp(join(tmpdir(), "cli-uwf-roundtrip-test-"));
|
|
31
33
|
});
|
|
32
34
|
|
|
33
35
|
afterEach(async () => {
|
|
36
|
+
if (savedOcasHome === undefined) {
|
|
37
|
+
delete process.env.OCAS_HOME;
|
|
38
|
+
} else {
|
|
39
|
+
process.env.OCAS_HOME = savedOcasHome;
|
|
40
|
+
}
|
|
34
41
|
await rm(tmpDir, { recursive: true, force: true });
|
|
35
42
|
});
|
|
36
43
|
|
|
@@ -131,7 +138,7 @@ describe("C1: adapter JSON round-trip integration", () => {
|
|
|
131
138
|
try {
|
|
132
139
|
stdout = execFileSync(
|
|
133
140
|
process.execPath,
|
|
134
|
-
[cliPath, "thread", "exec", threadId, "--agent", mockAgentPath],
|
|
141
|
+
[cliPath, "--format", "raw-json", "thread", "exec", threadId, "--agent", mockAgentPath],
|
|
135
142
|
{
|
|
136
143
|
encoding: "utf8",
|
|
137
144
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -162,15 +169,17 @@ describe("C1: adapter JSON round-trip integration", () => {
|
|
|
162
169
|
throw new Error(`CLI exited with code ${exitCode}\nstdout: ${stdout}\nstderr: ${stderr}`);
|
|
163
170
|
}
|
|
164
171
|
|
|
165
|
-
// Parse CLI output
|
|
172
|
+
// Parse CLI output (raw-json envelope value: { threadId, workflowHash, steps: [...] })
|
|
166
173
|
const cliOutput = JSON.parse(stdout.trim());
|
|
167
|
-
expect(cliOutput).toHaveProperty("
|
|
168
|
-
expect(cliOutput).
|
|
169
|
-
|
|
174
|
+
expect(cliOutput).toHaveProperty("threadId", threadId);
|
|
175
|
+
expect(cliOutput.steps).toHaveLength(1);
|
|
176
|
+
const firstStep = cliOutput.steps[0];
|
|
177
|
+
expect(firstStep).toHaveProperty("head", stepHash);
|
|
178
|
+
expect(firstStep.head).toMatch(/^[0-9A-HJ-NP-TV-Z]{13}$/);
|
|
170
179
|
|
|
171
180
|
// Verify the CAS step node exists and has correct metadata
|
|
172
181
|
const storeAfter = await openStore(casDir);
|
|
173
|
-
const stepNode = storeAfter.cas.get(
|
|
182
|
+
const stepNode = storeAfter.cas.get(firstStep.head as CasRef);
|
|
174
183
|
expect(stepNode).not.toBeNull();
|
|
175
184
|
|
|
176
185
|
const payload = stepNode!.payload as StepNodePayload;
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import { mkdir, mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
acquireSlot,
|
|
8
|
+
cleanStaleSlots,
|
|
9
|
+
countActiveSlots,
|
|
10
|
+
DEFAULT_MAX_RUNNING,
|
|
11
|
+
getSlotsDir,
|
|
12
|
+
installSlotCleanup,
|
|
13
|
+
} from "../concurrency/index.js";
|
|
14
|
+
|
|
15
|
+
// ── test setup ────────────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
let tmpDir: string;
|
|
18
|
+
|
|
19
|
+
beforeEach(async () => {
|
|
20
|
+
tmpDir = await mkdtemp(join(tmpdir(), "concurrency-test-"));
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
afterEach(async () => {
|
|
24
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// ── Spec: concurrency-acquire-slot-under-limit ──────────────────────────────
|
|
28
|
+
|
|
29
|
+
describe("acquireSlot succeeds immediately when below maxRunning", () => {
|
|
30
|
+
test("creates slot file and returns SlotHandle when under limit", async () => {
|
|
31
|
+
const handle = await acquireSlot(tmpDir, 2);
|
|
32
|
+
|
|
33
|
+
// Slot file exists
|
|
34
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
35
|
+
const files = await readdir(slotsDir);
|
|
36
|
+
expect(files).toContain(`${process.pid}.slot`);
|
|
37
|
+
|
|
38
|
+
// Returns a SlotHandle with release()
|
|
39
|
+
expect(handle).toHaveProperty("release");
|
|
40
|
+
expect(typeof handle.release).toBe("function");
|
|
41
|
+
|
|
42
|
+
// countActiveSlots returns 1
|
|
43
|
+
const count = await countActiveSlots(tmpDir);
|
|
44
|
+
expect(count).toBe(1);
|
|
45
|
+
|
|
46
|
+
// Cleanup
|
|
47
|
+
await handle.release();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test("returns immediately (no blocking) when slots available", async () => {
|
|
51
|
+
const start = Date.now();
|
|
52
|
+
const handle = await acquireSlot(tmpDir, 2);
|
|
53
|
+
const elapsed = Date.now() - start;
|
|
54
|
+
|
|
55
|
+
// Should complete in well under 1 second (no polling delay)
|
|
56
|
+
expect(elapsed).toBeLessThan(500);
|
|
57
|
+
|
|
58
|
+
await handle.release();
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// ── Spec: concurrency-acquire-slot-blocks-at-limit ──────────────────────────
|
|
63
|
+
|
|
64
|
+
describe("acquireSlot blocks when at capacity", () => {
|
|
65
|
+
test("calls onWaiting when all slots are occupied", async () => {
|
|
66
|
+
// Create a slot file for a "live" process — use parent PID (same user, signalable)
|
|
67
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
68
|
+
await mkdir(slotsDir, { recursive: true });
|
|
69
|
+
const blockerPid = process.ppid;
|
|
70
|
+
await writeFile(join(slotsDir, `${blockerPid}.slot`), "", "utf8");
|
|
71
|
+
|
|
72
|
+
const onWaiting = vi.fn();
|
|
73
|
+
const onAcquired = vi.fn();
|
|
74
|
+
|
|
75
|
+
// maxRunning=1, one slot occupied → should block
|
|
76
|
+
// Release the blocking slot after a brief delay
|
|
77
|
+
setTimeout(async () => {
|
|
78
|
+
await rm(join(slotsDir, `${blockerPid}.slot`), { force: true });
|
|
79
|
+
}, 200);
|
|
80
|
+
|
|
81
|
+
const handle = await acquireSlot(tmpDir, 1, {
|
|
82
|
+
onWaiting,
|
|
83
|
+
onAcquired,
|
|
84
|
+
pollIntervalMs: 100,
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
expect(onWaiting).toHaveBeenCalled();
|
|
88
|
+
expect(onAcquired).toHaveBeenCalled();
|
|
89
|
+
|
|
90
|
+
await handle.release();
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
test("polls with interval and proceeds after slot is freed", async () => {
|
|
94
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
95
|
+
await mkdir(slotsDir, { recursive: true });
|
|
96
|
+
const blockerPid = process.ppid;
|
|
97
|
+
await writeFile(join(slotsDir, `${blockerPid}.slot`), "", "utf8");
|
|
98
|
+
|
|
99
|
+
// Remove after 250ms
|
|
100
|
+
setTimeout(async () => {
|
|
101
|
+
await rm(join(slotsDir, `${blockerPid}.slot`), { force: true });
|
|
102
|
+
}, 250);
|
|
103
|
+
|
|
104
|
+
const start = Date.now();
|
|
105
|
+
const handle = await acquireSlot(tmpDir, 1, { pollIntervalMs: 100 });
|
|
106
|
+
const elapsed = Date.now() - start;
|
|
107
|
+
|
|
108
|
+
// Should have waited at least ~200ms (polling)
|
|
109
|
+
expect(elapsed).toBeGreaterThanOrEqual(150);
|
|
110
|
+
|
|
111
|
+
await handle.release();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// ── Spec: concurrency-stale-slot-cleanup ────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
describe("cleanStaleSlots removes slot files for dead PIDs", () => {
|
|
118
|
+
test("removes slot file for dead PID, preserves live PID", async () => {
|
|
119
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
120
|
+
await mkdir(slotsDir, { recursive: true });
|
|
121
|
+
|
|
122
|
+
// Dead PID (99999999 should not exist)
|
|
123
|
+
await writeFile(join(slotsDir, "99999999.slot"), "", "utf8");
|
|
124
|
+
// Live PID (current process)
|
|
125
|
+
await writeFile(join(slotsDir, `${process.pid}.slot`), "", "utf8");
|
|
126
|
+
|
|
127
|
+
const cleaned = await cleanStaleSlots(tmpDir);
|
|
128
|
+
expect(cleaned).toBe(1);
|
|
129
|
+
|
|
130
|
+
const files = await readdir(slotsDir);
|
|
131
|
+
expect(files).not.toContain("99999999.slot");
|
|
132
|
+
expect(files).toContain(`${process.pid}.slot`);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
test("countActiveSlots reflects correct count after cleanup", async () => {
|
|
136
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
137
|
+
await mkdir(slotsDir, { recursive: true });
|
|
138
|
+
|
|
139
|
+
// 1 dead + 1 live
|
|
140
|
+
await writeFile(join(slotsDir, "99999999.slot"), "", "utf8");
|
|
141
|
+
await writeFile(join(slotsDir, `${process.pid}.slot`), "", "utf8");
|
|
142
|
+
|
|
143
|
+
// Before cleanup: 2 files
|
|
144
|
+
const beforeFiles = await readdir(slotsDir);
|
|
145
|
+
expect(beforeFiles.filter((f) => f.endsWith(".slot")).length).toBe(2);
|
|
146
|
+
|
|
147
|
+
await cleanStaleSlots(tmpDir);
|
|
148
|
+
|
|
149
|
+
// After cleanup
|
|
150
|
+
const count = await countActiveSlots(tmpDir);
|
|
151
|
+
expect(count).toBe(1);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// ── Spec: concurrency-race-protection-rollback ──────────────────────────────
|
|
156
|
+
|
|
157
|
+
describe("acquireSlot rolls back on race condition", () => {
|
|
158
|
+
test("rolls back slot file if post-write count exceeds maxRunning", async () => {
|
|
159
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
160
|
+
await mkdir(slotsDir, { recursive: true });
|
|
161
|
+
|
|
162
|
+
// Simulate: maxRunning=2, and we already have 1 slot from another live process
|
|
163
|
+
const blockerPid = process.ppid;
|
|
164
|
+
await writeFile(join(slotsDir, `${blockerPid}.slot`), "", "utf8");
|
|
165
|
+
|
|
166
|
+
// Our process writes its slot, making count=2 which equals maxRunning=2
|
|
167
|
+
// This should succeed (at limit, not over)
|
|
168
|
+
const handle = await acquireSlot(tmpDir, 2);
|
|
169
|
+
const count = await countActiveSlots(tmpDir);
|
|
170
|
+
expect(count).toBe(2);
|
|
171
|
+
|
|
172
|
+
await handle.release();
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
test("when another slot appears during write, rollback occurs", async () => {
|
|
176
|
+
// This tests the double-check logic. We'll simulate by pre-filling to capacity.
|
|
177
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
178
|
+
await mkdir(slotsDir, { recursive: true });
|
|
179
|
+
|
|
180
|
+
// maxRunning=1, one slot already occupied by parent PID
|
|
181
|
+
const blockerPid = process.ppid;
|
|
182
|
+
await writeFile(join(slotsDir, `${blockerPid}.slot`), "", "utf8");
|
|
183
|
+
|
|
184
|
+
// Release after delay so acquireSlot can proceed
|
|
185
|
+
setTimeout(async () => {
|
|
186
|
+
await rm(join(slotsDir, `${blockerPid}.slot`), { force: true });
|
|
187
|
+
}, 200);
|
|
188
|
+
|
|
189
|
+
const handle = await acquireSlot(tmpDir, 1, { pollIntervalMs: 100 });
|
|
190
|
+
|
|
191
|
+
// After acquiring, only our slot should exist
|
|
192
|
+
const files = await readdir(slotsDir);
|
|
193
|
+
const slotFiles = files.filter((f) => f.endsWith(".slot"));
|
|
194
|
+
expect(slotFiles).toContain(`${process.pid}.slot`);
|
|
195
|
+
|
|
196
|
+
await handle.release();
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
// ── Spec: concurrency-exec-signal-cleanup ────────────────────────────────────
|
|
201
|
+
|
|
202
|
+
describe("installSlotCleanup removes slot on signal", () => {
|
|
203
|
+
test("release function removes slot file", async () => {
|
|
204
|
+
const handle = await acquireSlot(tmpDir, 2);
|
|
205
|
+
|
|
206
|
+
// Verify slot exists
|
|
207
|
+
const slotsDir = getSlotsDir(tmpDir);
|
|
208
|
+
const filesBefore = await readdir(slotsDir);
|
|
209
|
+
expect(filesBefore).toContain(`${process.pid}.slot`);
|
|
210
|
+
|
|
211
|
+
// installSlotCleanup returns a cleanup function
|
|
212
|
+
const cleanup = installSlotCleanup(handle);
|
|
213
|
+
|
|
214
|
+
// Call release directly (simulating what signal handler would do)
|
|
215
|
+
await handle.release();
|
|
216
|
+
|
|
217
|
+
const filesAfter = await readdir(slotsDir);
|
|
218
|
+
expect(filesAfter).not.toContain(`${process.pid}.slot`);
|
|
219
|
+
|
|
220
|
+
// Uninstall the cleanup handler
|
|
221
|
+
cleanup();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
// ── Spec: concurrency-default-max-running ────────────────────────────────────
|
|
226
|
+
|
|
227
|
+
describe("DEFAULT_MAX_RUNNING is 2", () => {
|
|
228
|
+
test("constant equals 2", () => {
|
|
229
|
+
expect(DEFAULT_MAX_RUNNING).toBe(2);
|
|
230
|
+
});
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
// ── Spec: concurrency-exec-uses-slot (unit level) ───────────────────────────
|
|
234
|
+
|
|
235
|
+
describe("slot lifecycle during exec", () => {
|
|
236
|
+
test("acquireSlot + release = 0 active slots", async () => {
|
|
237
|
+
const handle = await acquireSlot(tmpDir, 2);
|
|
238
|
+
expect(await countActiveSlots(tmpDir)).toBe(1);
|
|
239
|
+
|
|
240
|
+
await handle.release();
|
|
241
|
+
expect(await countActiveSlots(tmpDir)).toBe(0);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("release is idempotent", async () => {
|
|
245
|
+
const handle = await acquireSlot(tmpDir, 2);
|
|
246
|
+
await handle.release();
|
|
247
|
+
// Calling release again should not throw
|
|
248
|
+
await handle.release();
|
|
249
|
+
expect(await countActiveSlots(tmpDir)).toBe(0);
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
// ── Spec: concurrency-config-set-max-running ─────────────────────────────────
|
|
254
|
+
|
|
255
|
+
describe("config set concurrency.maxRunning", () => {
|
|
256
|
+
test("concurrency config key is validated correctly", async () => {
|
|
257
|
+
// Import config module to test the key validation
|
|
258
|
+
const { parseDotPath, setNestedValue } = await import("../commands/config.js");
|
|
259
|
+
|
|
260
|
+
const config: Record<string, unknown> = {};
|
|
261
|
+
const path = parseDotPath("concurrency.maxRunning");
|
|
262
|
+
setNestedValue(config, path, 3);
|
|
263
|
+
|
|
264
|
+
expect(config).toEqual({ concurrency: { maxRunning: 3 } });
|
|
265
|
+
});
|
|
266
|
+
});
|