@leing2021/super-pi 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +38 -209
  2. package/extensions/ce-core/index.ts +190 -7
  3. package/extensions/ce-core/tools/parallel-subagent.ts +3 -3
  4. package/extensions/ce-core/tools/subagent.ts +2 -2
  5. package/package.json +4 -18
  6. package/rules/common/naming.md +154 -0
  7. package/skills/02-plan/SKILL.md +3 -2
  8. package/skills/03-work/SKILL.md +9 -6
  9. package/skills/04-review/SKILL.md +3 -2
  10. package/skills/06-next/SKILL.md +38 -10
  11. package/skills/06-next/references/recommendation-logic.md +2 -2
  12. package/skills/07-worktree/SKILL.md +9 -8
  13. package/skills/{09-help → 08-help}/SKILL.md +3 -3
  14. package/skills/{09-help → 08-help}/references/workflow-sequence.md +2 -1
  15. package/skills/references/language-detection.md +44 -0
  16. package/extensions/subagent/agent-management.ts +0 -595
  17. package/extensions/subagent/agent-manager-chain-detail.ts +0 -162
  18. package/extensions/subagent/agent-manager-detail.ts +0 -231
  19. package/extensions/subagent/agent-manager-edit.ts +0 -390
  20. package/extensions/subagent/agent-manager-list.ts +0 -278
  21. package/extensions/subagent/agent-manager-parallel.ts +0 -304
  22. package/extensions/subagent/agent-manager.ts +0 -705
  23. package/extensions/subagent/agent-scope.ts +0 -8
  24. package/extensions/subagent/agent-selection.ts +0 -25
  25. package/extensions/subagent/agent-serializer.ts +0 -123
  26. package/extensions/subagent/agent-templates.ts +0 -62
  27. package/extensions/subagent/agents/context-builder.md +0 -37
  28. package/extensions/subagent/agents/delegate.md +0 -9
  29. package/extensions/subagent/agents/oracle.md +0 -73
  30. package/extensions/subagent/agents/planner.md +0 -52
  31. package/extensions/subagent/agents/researcher.md +0 -50
  32. package/extensions/subagent/agents/reviewer.md +0 -38
  33. package/extensions/subagent/agents/scout.md +0 -48
  34. package/extensions/subagent/agents/worker.md +0 -52
  35. package/extensions/subagent/agents.ts +0 -761
  36. package/extensions/subagent/artifacts.ts +0 -100
  37. package/extensions/subagent/async-execution.ts +0 -520
  38. package/extensions/subagent/async-job-tracker.ts +0 -216
  39. package/extensions/subagent/async-status.ts +0 -241
  40. package/extensions/subagent/chain-clarify.ts +0 -1364
  41. package/extensions/subagent/chain-execution.ts +0 -853
  42. package/extensions/subagent/chain-serializer.ts +0 -126
  43. package/extensions/subagent/completion-dedupe.ts +0 -65
  44. package/extensions/subagent/doctor.ts +0 -200
  45. package/extensions/subagent/execution.ts +0 -738
  46. package/extensions/subagent/file-coalescer.ts +0 -42
  47. package/extensions/subagent/fork-context.ts +0 -63
  48. package/extensions/subagent/formatters.ts +0 -122
  49. package/extensions/subagent/frontmatter.ts +0 -31
  50. package/extensions/subagent/index.ts +0 -585
  51. package/extensions/subagent/intercom-bridge.ts +0 -240
  52. package/extensions/subagent/jsonl-writer.ts +0 -83
  53. package/extensions/subagent/model-fallback.ts +0 -108
  54. package/extensions/subagent/notify.ts +0 -110
  55. package/extensions/subagent/parallel-utils.ts +0 -108
  56. package/extensions/subagent/pi-args.ts +0 -138
  57. package/extensions/subagent/pi-spawn.ts +0 -100
  58. package/extensions/subagent/post-exit-stdio-guard.ts +0 -87
  59. package/extensions/subagent/prompt-template-bridge.ts +0 -399
  60. package/extensions/subagent/prompts/gather-context-and-clarify.md +0 -13
  61. package/extensions/subagent/prompts/parallel-cleanup.md +0 -42
  62. package/extensions/subagent/prompts/parallel-research.md +0 -50
  63. package/extensions/subagent/prompts/parallel-review.md +0 -40
  64. package/extensions/subagent/render-helpers.ts +0 -82
  65. package/extensions/subagent/render.ts +0 -836
  66. package/extensions/subagent/result-intercom.ts +0 -237
  67. package/extensions/subagent/result-watcher.ts +0 -171
  68. package/extensions/subagent/run-history.ts +0 -57
  69. package/extensions/subagent/run-status.ts +0 -136
  70. package/extensions/subagent/schemas.ts +0 -164
  71. package/extensions/subagent/session-tokens.ts +0 -50
  72. package/extensions/subagent/settings.ts +0 -367
  73. package/extensions/subagent/single-output.ts +0 -97
  74. package/extensions/subagent/skills.ts +0 -626
  75. package/extensions/subagent/slash-bridge.ts +0 -176
  76. package/extensions/subagent/slash-commands.ts +0 -303
  77. package/extensions/subagent/slash-live-state.ts +0 -294
  78. package/extensions/subagent/subagent-control.ts +0 -150
  79. package/extensions/subagent/subagent-executor.ts +0 -1899
  80. package/extensions/subagent/subagent-prompt-runtime.ts +0 -75
  81. package/extensions/subagent/subagent-runner.ts +0 -1470
  82. package/extensions/subagent/subagents-status.ts +0 -472
  83. package/extensions/subagent/text-editor.ts +0 -272
  84. package/extensions/subagent/top-level-async.ts +0 -15
  85. package/extensions/subagent/types.ts +0 -623
  86. package/extensions/subagent/utils.ts +0 -456
  87. package/extensions/subagent/worktree.ts +0 -579
  88. package/extensions/super-pi-extension/agents/ce-oracle.md +0 -109
  89. package/extensions/super-pi-extension/agents/ce-planner.md +0 -116
  90. package/extensions/super-pi-extension/agents/ce-reviewer.md +0 -99
  91. package/extensions/super-pi-extension/agents/ce-scout.md +0 -80
  92. package/extensions/super-pi-extension/agents/ce-worker.md +0 -78
  93. package/extensions/super-pi-extension/chains/ce-parallel-review.chain.md +0 -34
  94. package/extensions/super-pi-extension/chains/ce-review-only.chain.md +0 -12
  95. package/extensions/super-pi-extension/chains/ce-standard.chain.md +0 -28
  96. package/extensions/super-pi-extension/index.ts +0 -129
  97. package/extensions/super-pi-extension/model-sync.ts +0 -204
  98. package/skills/08-status/SKILL.md +0 -41
  99. package/skills/08-status/references/artifact-locations.md +0 -10
  100. package/skills/10-rules/SKILL.md +0 -76
  101. package/skills/pi-subagents/SKILL.md +0 -566
@@ -4,23 +4,25 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent"
4
4
  import { Type } from "typebox"
5
5
  import { createArtifactHelperTool, type ArtifactType } from "./tools/artifact-helper"
6
6
  import { createAskUserQuestionTool } from "./tools/ask-user-question"
7
+ import { createSubagentTool } from "./tools/subagent"
7
8
  import { createWorkflowStateTool } from "./tools/workflow-state"
8
9
  import { createWorktreeManagerTool } from "./tools/worktree-manager"
9
10
  import { createReviewRouterTool } from "./tools/review-router"
11
+ import { createParallelSubagentTool } from "./tools/parallel-subagent"
10
12
  import { createSessionCheckpointTool } from "./tools/session-checkpoint"
11
13
  import { createTaskSplitterTool } from "./tools/task-splitter"
12
14
  import { createBrainstormDialogTool } from "./tools/brainstorm-dialog"
13
15
  import { createPlanDiffTool } from "./tools/plan-diff"
14
16
  import { createSessionHistoryTool } from "./tools/session-history"
15
17
  import { createPatternExtractorTool } from "./tools/pattern-extractor"
18
+ import { createContextHandoffTool } from "./tools/context-handoff"
16
19
  import { filterBashOutput } from "./tools/bash-output-filter"
17
20
  import { filterReadOutput } from "./tools/read-output-filter"
18
21
  import { COMPACTION_FOCUS_INSTRUCTIONS } from "./tools/compaction-optimizer"
22
+ import { AsyncMutex } from "./tools/async-mutex"
23
+ import type { SubagentExecOptions, SubagentRunner } from "./tools/subagent"
19
24
 
20
- // NOTE: subagent and parallel_subagent tool registration removed.
21
- // Subagent capabilities are provided by the pi-subagents package.
22
- // super-pi focuses on CE-specific tools only.
23
-
25
+ const _subagentEnvMutex = new AsyncMutex()
24
26
  const PIPELINE_STAGE_KEYS = new Set([
25
27
  "01-brainstorm",
26
28
  "02-plan",
@@ -81,6 +83,47 @@ function parseModelRef(
81
83
  }
82
84
  }
83
85
 
86
+ /**
87
+ * Create a subagent runner that handles env injection with mutex protection
88
+ * for concurrency safety when multiple parallel subagents share the process.
89
+ */
90
+ function createSubagentRunner(
91
+ pi: ExtensionAPI,
92
+ signal?: AbortSignal,
93
+ ): SubagentRunner {
94
+ return async (prompt: string, options?: SubagentExecOptions) => {
95
+ const args = ["--no-session", ...(options?.extraFlags ?? []), "-p", prompt]
96
+ const release = await _subagentEnvMutex.acquire()
97
+ const savedEnv: Record<string, string | undefined> = {}
98
+ const extraEnv = options?.extraEnv ?? {}
99
+ for (const [key, value] of Object.entries(extraEnv)) {
100
+ savedEnv[key] = process.env[key]
101
+ process.env[key] = value
102
+ }
103
+ try {
104
+ const execResult = await pi.exec("pi", args, {
105
+ signal,
106
+ timeout: 10 * 60 * 1000,
107
+ })
108
+
109
+ if (execResult.code !== 0) {
110
+ throw new Error(execResult.stderr || execResult.stdout || `Subagent failed for prompt: ${prompt}`)
111
+ }
112
+
113
+ return (execResult.stdout || "").trim()
114
+ } finally {
115
+ for (const [key, oldValue] of Object.entries(savedEnv)) {
116
+ if (oldValue === undefined) {
117
+ delete process.env[key]
118
+ } else {
119
+ process.env[key] = oldValue
120
+ }
121
+ }
122
+ release()
123
+ }
124
+ }
125
+ }
126
+
84
127
  const artifactHelperParams = Type.Object({
85
128
  repoRoot: Type.String({ description: "Repository root where workflow artifacts should be created" }),
86
129
  artifactType: Type.Union([
@@ -103,6 +146,18 @@ const askUserQuestionParams = Type.Object({
103
146
  allowCustom: Type.Optional(Type.Boolean({ description: "Allow a custom answer when options are present" })),
104
147
  })
105
148
 
149
+ const subagentTaskSchema = Type.Object({
150
+ agent: Type.String({ description: "Skill name to invoke via /skill:<name>" }),
151
+ task: Type.String({ description: "Task text passed to the subagent" }),
152
+ })
153
+
154
+ const subagentParams = Type.Object({
155
+ agent: Type.Optional(Type.String({ description: "Single subagent skill name" })),
156
+ task: Type.Optional(Type.String({ description: "Single subagent task" })),
157
+ chain: Type.Optional(Type.Array(subagentTaskSchema, { description: "Serial subagent chain with optional {previous} placeholder" })),
158
+ inheritSkills: Type.Optional(Type.Boolean({ description: "Whether the subagent should inherit skills. Default: true" })),
159
+ })
160
+
106
161
  const workflowStateParams = Type.Object({
107
162
  repoRoot: Type.String({ description: "Repository root to scan for workflow artifacts" }),
108
163
  })
@@ -125,6 +180,19 @@ const reviewRouterParams = Type.Object({
125
180
  deletions: Type.Number({ description: "Number of lines removed" }),
126
181
  })
127
182
 
183
+ const parallelSubagentTaskSchema = Type.Object({
184
+ agent: Type.String({ description: "Skill name to invoke via /skill:<name>" }),
185
+ task: Type.String({ description: "Task text passed to the subagent" }),
186
+ })
187
+
188
+ const parallelSubagentParams = Type.Object({
189
+ tasks: Type.Union([
190
+ Type.Array(parallelSubagentTaskSchema),
191
+ Type.String({ description: "JSON stringified array of tasks" }),
192
+ ], { description: "Array of independent tasks to run concurrently (can be a JSON string)" }),
193
+ inheritSkills: Type.Optional(Type.Boolean({ description: "Whether subagents should inherit skills. Default: false" })),
194
+ })
195
+
128
196
  const sessionCheckpointParams = Type.Object({
129
197
  operation: Type.Union([
130
198
  Type.Literal("save"),
@@ -205,6 +273,30 @@ const patternSchema = Type.Object({
205
273
  sources: Type.Array(Type.String(), { description: "Artifact sources" }),
206
274
  })
207
275
 
276
+ const contextHandoffParams = Type.Object({
277
+ operation: Type.Union([
278
+ Type.Literal("save"),
279
+ Type.Literal("load"),
280
+ Type.Literal("latest"),
281
+ Type.Literal("status"),
282
+ ], { description: "Handoff operation" }),
283
+ repoRoot: Type.String({ description: "Repository root" }),
284
+ currentStage: Type.Optional(Type.String({ description: "Current pipeline stage (e.g. 02-plan)" })),
285
+ nextStage: Type.Optional(Type.String({ description: "Next pipeline stage" })),
286
+ contextHealth: Type.Optional(Type.Union([
287
+ Type.Literal("good"),
288
+ Type.Literal("watch"),
289
+ Type.Literal("heavy"),
290
+ Type.Literal("critical"),
291
+ ], { description: "Context health assessment" })),
292
+ activeFiles: Type.Optional(Type.Array(Type.String(), { description: "1-5 must-know active file paths" })),
293
+ blocker: Type.Optional(Type.String({ description: "Current blocker description" })),
294
+ verification: Type.Optional(Type.String({ description: "Latest verification command + result" })),
295
+ artifacts: Type.Optional(Type.Record(Type.String(), Type.Optional(Type.String()), { description: "Artifact paths (requirements, plan, checkpoint, proof)" })),
296
+ handoffMarkdown: Type.Optional(Type.String({ description: "Custom handoff markdown content" })),
297
+ handoffPath: Type.Optional(Type.String({ description: "Specific handoff file path to load" })),
298
+ })
299
+
208
300
  const patternExtractorParams = Type.Object({
209
301
  operation: Type.Union([
210
302
  Type.Literal("extract"),
@@ -275,15 +367,18 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
275
367
 
276
368
  const artifactHelper = createArtifactHelperTool()
277
369
  const askUserQuestion = createAskUserQuestionTool()
370
+ const subagent = createSubagentTool()
278
371
  const workflowState = createWorkflowStateTool()
279
372
  const worktreeManager = createWorktreeManagerTool()
280
373
  const reviewRouter = createReviewRouterTool()
374
+ const parallelSubagent = createParallelSubagentTool()
281
375
  const sessionCheckpoint = createSessionCheckpointTool()
282
376
  const taskSplitter = createTaskSplitterTool()
283
377
  const brainstormDialog = createBrainstormDialogTool()
284
378
  const planDiff = createPlanDiffTool()
285
379
  const sessionHistory = createSessionHistoryTool()
286
380
  const patternExtractor = createPatternExtractorTool()
381
+ const contextHandoff = createContextHandoffTool()
287
382
 
288
383
  pi.registerTool({
289
384
  name: artifactHelper.name,
@@ -350,6 +445,29 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
350
445
  },
351
446
  })
352
447
 
448
+ pi.registerTool({
449
+ name: subagent.name,
450
+ label: "CE Subagent",
451
+ description: "Run a single CE skill-based subagent or a serial chain in an isolated Pi process.",
452
+ parameters: subagentParams,
453
+ async execute(_toolCallId, params, signal, _onUpdate, ctx) {
454
+ const result = await subagent.execute(
455
+ {
456
+ agent: params.agent,
457
+ task: params.task,
458
+ chain: params.chain,
459
+ inheritSkills: params.inheritSkills,
460
+ },
461
+ createSubagentRunner(pi, signal),
462
+ )
463
+
464
+ return {
465
+ content: [{ type: "text", text: result.outputs[result.outputs.length - 1] ?? "" }],
466
+ details: result,
467
+ }
468
+ },
469
+ })
470
+
353
471
  pi.registerTool({
354
472
  name: workflowState.name,
355
473
  label: "Workflow State",
@@ -421,6 +539,39 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
421
539
  },
422
540
  })
423
541
 
542
+ pi.registerTool({
543
+ name: parallelSubagent.name,
544
+ label: "CE Parallel Subagent",
545
+ description: "Run multiple CE skill-based subagent tasks concurrently. IMPORTANT: Provide 'tasks' as a clean JSON array object. If the environment forces a string, provide a valid JSON array string.",
546
+ parameters: parallelSubagentParams,
547
+ async execute(_toolCallId, params, signal) {
548
+ let tasks: any[]
549
+ if (typeof params.tasks === "string") {
550
+ try {
551
+ const cleaned = params.tasks.replace(/^```json\s*|```$/g, "").trim()
552
+ tasks = JSON.parse(cleaned)
553
+ } catch (e) {
554
+ throw new Error(`Failed to parse tasks string as JSON: ${e instanceof Error ? e.message : String(e)}`)
555
+ }
556
+ } else {
557
+ tasks = params.tasks
558
+ }
559
+
560
+ const result = await parallelSubagent.execute(
561
+ {
562
+ tasks,
563
+ inheritSkills: params.inheritSkills,
564
+ },
565
+ createSubagentRunner(pi, signal),
566
+ )
567
+
568
+ return {
569
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
570
+ details: result,
571
+ }
572
+ },
573
+ })
574
+
424
575
  pi.registerTool({
425
576
  name: sessionCheckpoint.name,
426
577
  label: "Session Checkpoint",
@@ -544,6 +695,33 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
544
695
  },
545
696
  })
546
697
 
698
+ pi.registerTool({
699
+ name: contextHandoff.name,
700
+ label: "Context Handoff",
701
+ description: "Manage cross-stage context handoffs with evidence-first templates. Supports save (write handoff + state), load (read handoff + state), latest (read latest dated handoff), and status (read current state).",
702
+ parameters: contextHandoffParams,
703
+ async execute(_toolCallId, params) {
704
+ const result = await contextHandoff.execute({
705
+ operation: params.operation,
706
+ repoRoot: params.repoRoot,
707
+ currentStage: params.currentStage,
708
+ nextStage: params.nextStage,
709
+ contextHealth: params.contextHealth,
710
+ activeFiles: params.activeFiles,
711
+ blocker: params.blocker,
712
+ verification: params.verification,
713
+ artifacts: params.artifacts as Record<string, string | undefined> | undefined,
714
+ handoffMarkdown: params.handoffMarkdown,
715
+ handoffPath: params.handoffPath,
716
+ })
717
+
718
+ return {
719
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
720
+ details: result,
721
+ }
722
+ },
723
+ })
724
+
547
725
  // Bash output smart filter — reduces context waste from verbose command output
548
726
  pi.on("tool_result", async (event, _ctx) => {
549
727
  if (event.toolName !== "bash") return undefined
@@ -587,8 +765,8 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
587
765
  if (event.toolName !== "read") return undefined
588
766
 
589
767
  // Extract path from input
590
- const filePath = (event.input as any)?.path ?? ""
591
- if (!filePath) return undefined
768
+ const path = (event.input as any)?.path ?? ""
769
+ if (!path) return undefined
592
770
 
593
771
  // Extract text content from tool result
594
772
  const textBlocks = (event.content as Array<any>)?.filter((b: any) => b.type === "text") ?? []
@@ -598,7 +776,7 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
598
776
  const isImage = (event.content as Array<any>)?.some((b: any) => b.type === "image") ?? false
599
777
 
600
778
  const result = filterReadOutput({
601
- path: filePath,
779
+ path,
602
780
  output,
603
781
  isError: event.isError ?? false,
604
782
  isImage,
@@ -631,15 +809,20 @@ export default function ceCoreExtension(pi: ExtensionAPI) {
631
809
 
632
810
  export { createArtifactHelperTool } from "./tools/artifact-helper"
633
811
  export { createAskUserQuestionTool } from "./tools/ask-user-question"
812
+ export { createSubagentTool } from "./tools/subagent"
813
+ export { checkSubagentDepth, getChildDepthEnv, DEFAULT_MAX_SUBAGENT_DEPTH } from "./tools/subagent-depth-guard"
814
+ export { AsyncMutex } from "./tools/async-mutex"
634
815
  export { createWorkflowStateTool } from "./tools/workflow-state"
635
816
  export { createWorktreeManagerTool } from "./tools/worktree-manager"
636
817
  export { createReviewRouterTool } from "./tools/review-router"
818
+ export { createParallelSubagentTool } from "./tools/parallel-subagent"
637
819
  export { createSessionCheckpointTool } from "./tools/session-checkpoint"
638
820
  export { createTaskSplitterTool } from "./tools/task-splitter"
639
821
  export { createBrainstormDialogTool } from "./tools/brainstorm-dialog"
640
822
  export { createPlanDiffTool } from "./tools/plan-diff"
641
823
  export { createSessionHistoryTool } from "./tools/session-history"
642
824
  export { createPatternExtractorTool } from "./tools/pattern-extractor"
825
+ export { createContextHandoffTool } from "./tools/context-handoff"
643
826
  export {
644
827
  getBrainstormArtifactPath,
645
828
  getPlanArtifactPath,
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parallel subagent tool — runs multiple skill-based subagent tasks concurrently.
2
+ * CE parallel subagent tool — runs multiple CE skill-based subagent tasks concurrently.
3
3
  *
4
4
  * Features:
5
5
  * - Recursion depth guard (PI_SUBAGENT_DEPTH / PI_SUBAGENT_MAX_DEPTH)
@@ -40,7 +40,7 @@ function buildPrompt(agent: string, task: string): string {
40
40
 
41
41
  export function createParallelSubagentTool() {
42
42
  return {
43
- name: "parallel_subagent",
43
+ name: "ce_parallel_subagent",
44
44
  async execute(input: ParallelSubagentInput, runner: SubagentRunner): Promise<ParallelSubagentResult> {
45
45
  // Recursion depth guard
46
46
  const depthCheck = checkSubagentDepth()
@@ -49,7 +49,7 @@ export function createParallelSubagentTool() {
49
49
  }
50
50
 
51
51
  if (!input.tasks || input.tasks.length === 0) {
52
- throw new Error("parallel_subagent requires at least one task")
52
+ throw new Error("ce_parallel_subagent requires at least one task")
53
53
  }
54
54
 
55
55
  // Default: parallel workers get a slim context (no inherited skills)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Subagent tool — runs a single skill-based subagent or a serial chain.
2
+ * CE subagent tool — runs a single CE skill-based subagent or a serial chain.
3
3
  *
4
4
  * Features:
5
5
  * - Recursion depth guard (PI_SUBAGENT_DEPTH / PI_SUBAGENT_MAX_DEPTH)
@@ -43,7 +43,7 @@ export type SubagentRunner = (
43
43
 
44
44
  export function createSubagentTool() {
45
45
  return {
46
- name: "subagent",
46
+ name: "ce_subagent",
47
47
  async execute(input: SubagentInput, runner: SubagentRunner): Promise<SubagentResult> {
48
48
  // Recursion depth guard
49
49
  const depthCheck = checkSubagentDepth()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leing2021/super-pi",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Pi-native Compound Engineering package for iterative development workflows",
@@ -35,10 +35,8 @@
35
35
  "test": "bun test"
36
36
  },
37
37
  "peerDependencies": {
38
- "@mariozechner/pi-coding-agent": "*"
39
- },
40
- "dependencies": {
41
- "typebox": "^1.1.24"
38
+ "@mariozechner/pi-coding-agent": ">=0.69.0",
39
+ "typebox": ">=1.0.0"
42
40
  },
43
41
  "devDependencies": {
44
42
  "@mariozechner/pi-coding-agent": "0.69.0",
@@ -49,19 +47,7 @@
49
47
  "./skills"
50
48
  ],
51
49
  "extensions": [
52
- "./extensions",
53
- "./extensions/super-pi-extension",
54
- "./extensions/subagent"
55
- ],
56
- "agents": [
57
- "./extensions/super-pi-extension/agents",
58
- "./extensions/subagent/agents"
59
- ],
60
- "prompts": [
61
- "./extensions/subagent/prompts"
62
- ],
63
- "chains": [
64
- "./extensions/super-pi-extension/chains"
50
+ "./extensions"
65
51
  ]
66
52
  }
67
53
  }
@@ -0,0 +1,154 @@
1
+ # Naming Convention
2
+
3
+ > One rule: **use simple, everyday, low-ambiguity words. Avoid jargon, avoid vagueness.**
4
+
5
+ ---
6
+
7
+ ## Word Selection Priority
8
+
9
+ When naming anything — variables, types, states, API fields, database columns, queues, errors — follow this order:
10
+
11
+ | Priority | Strategy | Why |
12
+ |----------|----------|-----|
13
+ | 1 | Pick an everyday word first | Short, direct, anyone can understand |
14
+ | 2 | Check it's not vague | `good`, `ready`, `ok`, `normal` are too ambiguous |
15
+ | 3 | Check cross-role clarity | Engineers, reviewers, operators, auditors all understand it |
16
+ | 4 | Use a technical term only when precision demands it | Last resort |
17
+
18
+ **In short: clarity first, stability second, terminology last.**
19
+
20
+ ---
21
+
22
+ ## Recommended vs. Avoid
23
+
24
+ ### ✅ Prefer — short, direct, unambiguous
25
+
26
+ ```
27
+ Revise Blocked Reject Approve
28
+ Queue Escalate Notify Cancel
29
+ reason owner action next_fix
30
+ recheck_when
31
+ ```
32
+
33
+ ### ❌ Avoid — too vague
34
+
35
+ ```
36
+ good ready ok normal done
37
+ ```
38
+
39
+ Simple but not specific enough for system fields.
40
+
41
+ ### ❌ Avoid — too technical / abstract
42
+
43
+ ```
44
+ orchestration_resolution_state
45
+ deferred_adjudication_mode
46
+ remediation_projection
47
+ resolution_artifact
48
+ operationalized_exception_payload
49
+ ```
50
+
51
+ May be precise, but poor for cross-role collaboration and audit replay.
52
+
53
+ ### ❌ Avoid — too decorative / emotional
54
+
55
+ System fields must be stable. Don't use literary, emotional, or decorative names.
56
+
57
+ ---
58
+
59
+ ## Style by Context
60
+
61
+ | Context | Style | Example |
62
+ |---------|-------|---------|
63
+ | File names | kebab-case | `task-orchestrator.ts` |
64
+ | Type names | PascalCase | `TaskEnvelope` |
65
+ | Zod/TypeBox schema variables | PascalCase + `Schema` suffix | `TaskEnvelopeSchema` |
66
+ | Function names | camelCase | `evaluatePolicy` |
67
+ | Exported constants | camelCase | `stateTransitions`, `finalStates` |
68
+ | Database table names | snake_case | `task_records` |
69
+ | Database column names | snake_case | `state_version` |
70
+ | Environment variables | UPPER_SNAKE_CASE | `DATABASE_URL` |
71
+ | Package names | scoped kebab-case | `@org/types` |
72
+ | State / enum values | lowercase everyday words, snake_case for multi-word | `created`, `executing`, `result_ready` |
73
+ | Error classes | `*Error` (never `*Exception`) | `BudgetExhaustedError` |
74
+ | Queue names | semantic, kebab-case | `'task-execution'` (not `'execution_requested'`) |
75
+ | API routes | kebab-case, plural nouns | `/api/tasks`, `/api/audit-events` |
76
+
77
+ ---
78
+
79
+ ## Naming by Role
80
+
81
+ ### Public states — conversational
82
+
83
+ ```
84
+ Revise Blocked Reject Approved
85
+ Pending Executing Committed Cancelled
86
+ ```
87
+
88
+ ### Governance actions — direct verbs
89
+
90
+ ```
91
+ Notify Approve Queue Escalate
92
+ Pause Resume Discard Delegate
93
+ ```
94
+
95
+ ### Supporting fields — read like speech
96
+
97
+ ```
98
+ next_fix → what to fix next
99
+ recheck_when → when to re-check
100
+ reason → why
101
+ owner → who's responsible
102
+ action → what to do
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Two-Layer Naming
108
+
109
+ When a name needs different expressions in schema vs. UI:
110
+
111
+ | Layer | Strategy | Example |
112
+ |-------|----------|---------|
113
+ | Schema / code / database | More stable, precise | `state: 'revise_requested'` |
114
+ | UI / audit log / replay | More human-readable | "Revision needed" |
115
+
116
+ Connect the two layers with a mapping table. Don't define semantics twice.
117
+
118
+ ---
119
+
120
+ ## Self-Check Checklist
121
+
122
+ For every name, confirm:
123
+
124
+ ```
125
+ □ Can you understand it in 5 seconds?
126
+ □ Will different roles (engineer, reviewer, operator, auditor) interpret it the same way?
127
+ □ Is it readable in audit replay / logs?
128
+ □ Is it NOT a vague word (good/ok/ready/normal)?
129
+ □ Is it NOT over-technical jargon?
130
+ □ Does it follow the style rules above (case, separator)?
131
+ □ Is it consistent with existing names in the same domain?
132
+ ```
133
+
134
+ If any answer is "no" → pick a different word and re-check.
135
+
136
+ ---
137
+
138
+ ## Common Anti-Patterns & Fixes
139
+
140
+ | Anti-pattern | Problem | Fix |
141
+ |--------------|---------|-----|
142
+ | `status: 'good'` | Too vague | `status: 'passed'` |
143
+ | `state: 'orchestration_pending_resolution'` | Too technical | `state: 'waiting_approval'` |
144
+ | `action: 'the_moon_is_rising_retry'` | Too decorative | `action: 'retry'` |
145
+ | `flag: 'ok'` | Too vague | `flag: 'valid'` |
146
+ | `type: 'thing'` | Too generic | Use a concrete domain word |
147
+ | `err: SomethingException(...)` | Wrong convention | `err: SomethingError(...)` |
148
+ | `QUEUE = 'exec_req'` | Unclear abbreviation | `QUEUE = 'task-execution'` |
149
+
150
+ ---
151
+
152
+ ## One-Sentence Rule
153
+
154
+ > **Default to simple, conversational, low-ambiguity everyday words. If that creates ambiguity, keep the schema term stable and the UI / audit wording more human.**
@@ -11,11 +11,12 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
11
11
 
12
12
  ## Core rules
13
13
 
14
- - Before planning, read the `10-rules` skill and load:
14
+ - Before planning, load project rules:
15
15
  1. `rules/common/development-workflow.md` and `rules/common/testing.md`
16
- 2. **Detect the project's primary language** (check for `tsconfig.json` → typescript, `package.json` without tsconfig → javascript, `Cargo.toml` → rust, `go.mod` → golang, `pubspec.yaml` → dart, `pom.xml`/`build.gradle` → java, `*.sln`/`*.csproj` → csharp, `Package.swift` → swift, `requirements.txt`/`pyproject.toml`/`setup.py` → python, `composer.json` → php, `Makefile.PL`/`cpanfile` → perl, `build.gradle.kts` → kotlin)
16
+ 2. Detect the project's primary language using [language detection](../references/language-detection.md)
17
17
  3. Load all files in the matching language-specific rules directory (e.g. `rules/typescript/`)
18
18
  4. If the task involves frontend/browser concerns, also load `rules/web/` files
19
+ - Priority: project-level `{repo-root}/rules/` overrides package-level defaults
19
20
  - Search `docs/brainstorms/` for a relevant requirements artifact first.
20
21
  - Search solutions with grep-first strategy: extract keywords from the task → `bash grep -rl "tags:.*keyword" docs/solutions/ ~/.pi/agent/docs/solutions/` → read only frontmatter (first 15 lines) of matching files → score by severity + tag relevance → fully read top 3. Search both project-level (`docs/solutions/`) and global-level (`~/.pi/agent/docs/solutions/`). If no matches, report "No relevant solutions found" and proceed.
21
22
  - Write the final plan to `docs/plans/`.
@@ -11,18 +11,21 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
11
11
 
12
12
  ## Core rules
13
13
 
14
- - Before execution, read the `10-rules` skill and load:
14
+ - Before execution, load project rules:
15
15
  1. `rules/common/development-workflow.md` and `rules/common/testing.md`
16
- 2. **Detect the project's primary language** (check for `tsconfig.json` → typescript, `package.json` without tsconfig → javascript, `Cargo.toml` → rust, `go.mod` → golang, `pubspec.yaml` → dart, `pom.xml`/`build.gradle` → java, `*.sln`/`*.csproj` → csharp, `Package.swift` → swift, `requirements.txt`/`pyproject.toml`/`setup.py` → python, `composer.json` → php, `Makefile.PL`/`cpanfile` → perl, `build.gradle.kts` → kotlin)
16
+ 2. Detect the project's primary language using [language detection](../references/language-detection.md)
17
17
  3. Load all files in the matching language-specific rules directory (e.g. `rules/typescript/`)
18
18
  4. If the task involves frontend/browser concerns, also load `rules/web/` files
19
+ - Priority: project-level `{repo-root}/rules/` overrides package-level defaults
19
20
  - Distinguish between a **plan path** input and a **bare prompt** input before doing work.
20
21
  - Prefer deriving execution tasks from plan **implementation units**.
21
- - Use **serial subagents** (via `subagent` tool from pi-subagents) for tasks with dependencies.
22
- - Use **`subagent` tool in parallel mode** (via pi-subagents) for independent tasks that can run concurrently.
22
+ - Prefer inline execution for small or tightly scoped units.
23
+ - Use **`ce_parallel_subagent`** for independent CE skill-based units that can run concurrently.
24
+ - Use **`ce_subagent`** only for dependent serial chains that benefit from isolated context or specialized CE skill execution.
25
+ - Note: the generic `subagent` / `parallel_subagent` tool names are reserved for third-party agent extensions (e.g. `pi-subagents`); CE skill-router uses the `ce_`-prefixed names to avoid tool-name conflicts.
23
26
  - Use **`session_checkpoint`** to track plan execution progress. On start, load the checkpoint and skip completed units. After each unit, save the checkpoint.
24
27
  - On execution failure, use `session_checkpoint` `fail` to record the error, then `retry` to get a retry strategy. Follow the suggested strategy to recover.
25
- - Use **`task_splitter`** to analyze implementation units for file-level dependencies before execution. Run independent units via parallel subagents and dependent units serially.
28
+ - Use **`task_splitter`** to analyze implementation units for file-level dependencies before execution. Run independent units via `ce_parallel_subagent` and dependent units serially.
26
29
  - If inside a **worktree** (created via `07-worktree`), execute within it. Otherwise, consider recommending `07-worktree` for isolation.
27
30
  - End by recommending `04-review`.
28
31
 
@@ -48,7 +51,7 @@ Every execution step must follow **RED → GREEN → REFACTOR**:
48
51
  3. If it is a bare prompt, do a small scope scan before deciding whether to proceed.
49
52
  4. Use `session_checkpoint` to load progress and skip completed units.
50
53
  5. Use `task_splitter` to identify parallel-safe vs dependent units.
51
- 6. Execute in inline mode, serial subagents, or parallel subagents depending on task dependencies.
54
+ 6. Execute in inline mode by default; use `ce_parallel_subagent` for independent CE skill units and `ce_subagent` only for valuable dependent serial chains.
52
55
  7. For each unit, follow strict TDD:
53
56
  a. Run the RED test and confirm expected failure.
54
57
  b. Apply minimal implementation.
@@ -11,11 +11,12 @@ See [shared pipeline instructions](../references/pipeline-config.md) for model r
11
11
 
12
12
  ## Core rules
13
13
 
14
- - Before reviewing, read the `10-rules` skill and load:
14
+ - Before reviewing, load project rules:
15
15
  1. `rules/common/code-review.md`
16
- 2. **Detect the project's primary language** from the changed files (check for `tsconfig.json` → typescript, `package.json` without tsconfig → javascript, `Cargo.toml` → rust, `go.mod` → golang, `pubspec.yaml` → dart, `pom.xml`/`build.gradle` → java, `*.sln`/`*.csproj` → csharp, `Package.swift` → swift, `requirements.txt`/`pyproject.toml`/`setup.py` → python, `composer.json` → php, `Makefile.PL`/`cpanfile` → perl, `build.gradle.kts` → kotlin)
16
+ 2. Detect the project's primary language from the changed files using [language detection](../references/language-detection.md)
17
17
  3. Load all files in the matching language-specific rules directory (e.g. `rules/typescript/`)
18
18
  4. If the review involves frontend/browser changes, also load `rules/web/` files
19
+ - Priority: project-level `{repo-root}/rules/` overrides package-level defaults
19
20
  - Determine the **diff scope** before selecting reviewers.
20
21
  - Use the **`review_router`** tool to automatically select reviewer personas based on diff metadata.
21
22
  - Read the relevant **plan** artifact when one exists.