@shiwenbin1617/pstack 0.14.4
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/LICENSE +28 -0
- package/README.md +332 -0
- package/adapters/claude-code/overrides/setup-pstack/SKILL.md +48 -0
- package/adapters/claude-code.md +29 -0
- package/adapters/codex/agents/comment-sicko.toml +7 -0
- package/adapters/codex/agents/poteto-agent.toml +7 -0
- package/adapters/codex/overrides/setup-pstack/SKILL.md +40 -0
- package/adapters/codex.md +34 -0
- package/agents/comment-sicko.md +32 -0
- package/agents/poteto-agent.md +9 -0
- package/automations/benny/FOR_AGENTS.md +89 -0
- package/automations/benny/README.md +23 -0
- package/automations/benny/skills/reproduce-and-fix-issues/SKILL.md +310 -0
- package/automations/benny/skills/reproduce-and-fix-issues/references/control-adapter.md +169 -0
- package/automations/benny/skills/reproduce-and-fix-issues/references/feature-map.example.md +205 -0
- package/automations/benny/skills/reproduce-and-fix-issues/references/verify-existing-fix.md +93 -0
- package/automations/benny/skills/setup-benny/SKILL.md +266 -0
- package/automations/benny/skills/triage-issue-reports/SKILL.md +240 -0
- package/automations/benny/skills/triage-issue-reports/references/routing.example.md +61 -0
- package/automations/benny/templates/configuration.example.yaml +84 -0
- package/automations/benny/templates/reproduce-automation-prompt.md +33 -0
- package/automations/benny/templates/triage-automation-prompt.md +39 -0
- package/bin/pstack.mjs +331 -0
- package/package.json +48 -0
- package/scripts/build.mjs +218 -0
- package/scripts/host-adapters.mjs +128 -0
- package/scripts/lib.mjs +181 -0
- package/scripts/test.mjs +106 -0
- package/skills/architect/SKILL.md +83 -0
- package/skills/architect/references/design-red-flags.md +33 -0
- package/skills/architect/references/rationale-template.md +35 -0
- package/skills/architect/references/runner-prompt.md +20 -0
- package/skills/arena/SKILL.md +71 -0
- package/skills/automate-me/SKILL.md +109 -0
- package/skills/blast-radius/SKILL.md +50 -0
- package/skills/bro/SKILL.md +7 -0
- package/skills/create-verification-skill/SKILL.md +44 -0
- package/skills/create-verification-skill/references/feature-map-example/README.md +47 -0
- package/skills/create-verification-skill/references/feature-map-example/create-note.md +39 -0
- package/skills/create-verification-skill/references/feature-map-example/search.md +45 -0
- package/skills/figure-it-out/SKILL.md +55 -0
- package/skills/how/SKILL.md +134 -0
- package/skills/how/references/critic-prompt.md +59 -0
- package/skills/how/references/critique-rubric.md +58 -0
- package/skills/how/references/explainer-prompt.md +55 -0
- package/skills/how/references/explorer-prompt.md +52 -0
- package/skills/interrogate/SKILL.md +113 -0
- package/skills/interrogate/references/code-quality-review.md +47 -0
- package/skills/interrogate/references/lead-judgment.md +58 -0
- package/skills/interrogate/references/reviewer-prompt.md +72 -0
- package/skills/interrogate/references/rubric.md +77 -0
- package/skills/maintain-verification-skill/SKILL.md +39 -0
- package/skills/no-comments/SKILL.md +24 -0
- package/skills/poteto-mode/SKILL.md +140 -0
- package/skills/poteto-mode/playbooks/authoring-a-skill.md +12 -0
- package/skills/poteto-mode/playbooks/autonomous-run.md +13 -0
- package/skills/poteto-mode/playbooks/autopilot-full.md +13 -0
- package/skills/poteto-mode/playbooks/autopilot-stack.md +16 -0
- package/skills/poteto-mode/playbooks/babysit.md +27 -0
- package/skills/poteto-mode/playbooks/bug-fix.md +17 -0
- package/skills/poteto-mode/playbooks/eval.md +27 -0
- package/skills/poteto-mode/playbooks/feature.md +21 -0
- package/skills/poteto-mode/playbooks/hillclimb.md +21 -0
- package/skills/poteto-mode/playbooks/investigation.md +14 -0
- package/skills/poteto-mode/playbooks/multi-phase-plan.md +155 -0
- package/skills/poteto-mode/playbooks/opening-a-pr.md +29 -0
- package/skills/poteto-mode/playbooks/orchestrate.md +113 -0
- package/skills/poteto-mode/playbooks/pause-safely.md +10 -0
- package/skills/poteto-mode/playbooks/perf-issue.md +24 -0
- package/skills/poteto-mode/playbooks/prototype.md +14 -0
- package/skills/poteto-mode/playbooks/refactoring.md +16 -0
- package/skills/poteto-mode/playbooks/runtime-forensics.md +11 -0
- package/skills/poteto-mode/playbooks/session-pickup.md +13 -0
- package/skills/poteto-mode/playbooks/shipping.md +20 -0
- package/skills/poteto-mode/playbooks/trace-forensics.md +14 -0
- package/skills/poteto-mode/playbooks/visual-parity.md +11 -0
- package/skills/poteto-mode/playbooks/worktree-cleanup.md +14 -0
- package/skills/poteto-mode/references/bugbot-triage.md +142 -0
- package/skills/poteto-mode/scripts/bootstrap.ts +30 -0
- package/skills/poteto-mode/scripts/bun.lock +67 -0
- package/skills/poteto-mode/scripts/check-plan.mjs +186 -0
- package/skills/poteto-mode/scripts/orch/orch.test.ts +634 -0
- package/skills/poteto-mode/scripts/orch/orch.ts +578 -0
- package/skills/poteto-mode/scripts/orch/store.ts +1607 -0
- package/skills/poteto-mode/scripts/package.json +16 -0
- package/skills/poteto-mode/scripts/watch-pr/cli.test.ts +224 -0
- package/skills/poteto-mode/scripts/watch-pr/cli.ts +223 -0
- package/skills/poteto-mode/scripts/watch-pr/fakes.test-helper.ts +118 -0
- package/skills/poteto-mode/scripts/watch-pr/github.test.ts +306 -0
- package/skills/poteto-mode/scripts/watch-pr/github.ts +699 -0
- package/skills/poteto-mode/scripts/watch-pr/policy.test.ts +420 -0
- package/skills/poteto-mode/scripts/watch-pr/policy.ts +832 -0
- package/skills/poteto-mode/scripts/watch-pr/render.ts +169 -0
- package/skills/poteto-mode/scripts/watch-pr/tsconfig.json +13 -0
- package/skills/poteto-mode/scripts/watch-pr/types.compile.ts +93 -0
- package/skills/poteto-mode/scripts/watch-pr/types.ts +401 -0
- package/skills/poteto-mode/scripts/watch-pr/watch-pr +6 -0
- package/skills/poteto-mode/scripts/worktree-audit.sh +89 -0
- package/skills/principle-boundary-discipline/SKILL.md +34 -0
- package/skills/principle-build-the-lever/SKILL.md +23 -0
- package/skills/principle-encode-lessons-in-structure/SKILL.md +31 -0
- package/skills/principle-exhaust-the-design-space/SKILL.md +21 -0
- package/skills/principle-experience-first/SKILL.md +19 -0
- package/skills/principle-fix-root-causes/SKILL.md +23 -0
- package/skills/principle-foundational-thinking/SKILL.md +21 -0
- package/skills/principle-guard-the-context-window/SKILL.md +17 -0
- package/skills/principle-laziness-protocol/SKILL.md +18 -0
- package/skills/principle-make-operations-idempotent/SKILL.md +24 -0
- package/skills/principle-migrate-callers-then-delete-legacy-apis/SKILL.md +22 -0
- package/skills/principle-minimize-reader-load/SKILL.md +23 -0
- package/skills/principle-model-the-domain/SKILL.md +26 -0
- package/skills/principle-never-block-on-the-human/SKILL.md +23 -0
- package/skills/principle-outcome-oriented-execution/SKILL.md +22 -0
- package/skills/principle-prove-it-works/SKILL.md +33 -0
- package/skills/principle-redesign-from-first-principles/SKILL.md +16 -0
- package/skills/principle-separate-before-serializing-shared-state/SKILL.md +16 -0
- package/skills/principle-sequence-verifiable-units/SKILL.md +22 -0
- package/skills/principle-subtract-before-you-add/SKILL.md +22 -0
- package/skills/principle-type-system-discipline/SKILL.md +31 -0
- package/skills/recall/SKILL.md +35 -0
- package/skills/reflect/SKILL.md +77 -0
- package/skills/reflect/references/divergent-reviewer.md +43 -0
- package/skills/reflect/references/judgment-reviewer.md +42 -0
- package/skills/reflect/references/synthesizer.md +56 -0
- package/skills/reflect/references/tooling-reviewer.md +57 -0
- package/skills/setup-pstack/SKILL.md +106 -0
- package/skills/show-me-your-work/SKILL.md +82 -0
- package/skills/show-me-your-work/references/decision-log-template.tsv +1 -0
- package/skills/show-me-your-work/scripts/log.sh +40 -0
- package/skills/swarm/SKILL.md +46 -0
- package/skills/tdd/SKILL.md +44 -0
- package/skills/teach/SKILL.md +21 -0
- package/skills/technical-writing/SKILL.md +130 -0
- package/skills/typescript-best-practices/SKILL.md +28 -0
- package/skills/typescript-best-practices/references/patterns.md +292 -0
- package/skills/unslop/SKILL.md +80 -0
- package/skills/why/SKILL.md +229 -0
- package/skills/why/references/epistemics.md +144 -0
- package/skills/why/references/investigator-prompt.md +103 -0
- package/skills/why/references/source-playbook.md +17 -0
- package/skills/why/references/sources/code-archaeology.md +88 -0
- package/skills/why/references/sources/databricks.md +70 -0
- package/skills/why/references/sources/datadog.md +99 -0
- package/skills/why/references/sources/incident-postmortem.md +15 -0
- package/skills/why/references/sources/linear.md +48 -0
- package/skills/why/references/sources/notion.md +55 -0
- package/skills/why/references/sources/sentry.md +100 -0
- package/skills/why/references/sources/slack.md +54 -0
- package/skills/why/references/synthesizer-prompt.md +135 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, readdirSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
const CODEX_TRANSCRIPT = "`~/.codex/sessions/<yyyy>/<mm>/<dd>/rollout-*.jsonl`, filtered by the session metadata `cwd` for the active workspace";
|
|
5
|
+
const CLAUDE_TRANSCRIPT = "`~/.claude/projects/<slug>/<uuid>.jsonl`, where `<slug>` is the absolute workspace path with every `/` changed to `-`";
|
|
6
|
+
|
|
7
|
+
const CLAUDE_TRANSCRIPT_PARAGRAPH = /On Claude Code that is `~\/\.claude\/projects\/<slug>\/<uuid>\.jsonl`, where `<slug>` is[^.]*\.[\s\S]*?On Codex it is `~\/\.codex\/sessions\/<yyyy>\/<mm>\/<dd>\/rollout-\*\.jsonl`, which is not partitioned by workspace, so filter by the session's own cwd\./g;
|
|
8
|
+
|
|
9
|
+
function stripUnsupportedFrontmatter(text) {
|
|
10
|
+
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
11
|
+
if (!match) return text;
|
|
12
|
+
|
|
13
|
+
const kept = match[1]
|
|
14
|
+
.split(/\r?\n/)
|
|
15
|
+
.filter((line) => /^(name|description|metadata):/.test(line) || /^\s+/.test(line));
|
|
16
|
+
return `---\n${kept.join("\n")}\n---\n\n${text.slice(match[0].length)}`;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function replaceSkillInvocations(text, skillNames) {
|
|
20
|
+
const names = [...skillNames].sort((a, b) => b.length - a.length).join("|");
|
|
21
|
+
const invocation = new RegExp("/(?:" + names + ")(?=[\\s`,.)'\"]|$)", "g");
|
|
22
|
+
return text.replace(invocation, (value) => `$${value.slice(1)}`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function adaptCodexVocabulary(text) {
|
|
26
|
+
return text
|
|
27
|
+
.replace(CLAUDE_TRANSCRIPT_PARAGRAPH, `On Codex, transcripts live at ${CODEX_TRANSCRIPT}`)
|
|
28
|
+
.replace(/Transcripts live at `~\/\.claude\/projects\/<slug>\/<uuid>\.jsonl`[^\n]*/g, `Transcripts live at ${CODEX_TRANSCRIPT}. Scope every search to the active workspace.`)
|
|
29
|
+
.replace(/ls -t ~\/\.claude\/projects\/"\$\(pwd \| tr \/ -\)"\/\*\.jsonl 2>\/dev\/null \| head -10/g, "find ~/.codex/sessions -name 'rollout-*.jsonl' -type f -print")
|
|
30
|
+
.replace(/On Claude Code that is `subagent_type: Explore`\.?/g, "On Codex, use a custom agent with `sandbox_mode = \"read-only\"`.")
|
|
31
|
+
.replace(/using the Task tool/g, "using Codex subagent tools")
|
|
32
|
+
.replace(/Task tool's error message/g, "subagent tool's validation error")
|
|
33
|
+
.replace(/through the Task tool/g, "through Codex subagent tools")
|
|
34
|
+
.replace(/`run_in_background: true`/g, "concurrently")
|
|
35
|
+
.replace(/the `AskQuestion` tool \(structured multi-choice\)/g, "Codex's structured-question tool")
|
|
36
|
+
.replace(/About to `AskQuestion`/g, "About to ask the user with the structured-question tool")
|
|
37
|
+
.replace(/`AskQuestion`/g, "the structured-question tool")
|
|
38
|
+
.replace(/AskQuestion/g, "structured-question")
|
|
39
|
+
.replace(/\.claude\/skills\/<handle>\/\*\/` and `~\/\.claude\/skills\/<handle>\/\*\/` on Claude Code, `\.agents\/skills\/<handle>\/\*\/` and `~\/\.agents\/skills\/<handle>\/\*\/` on Codex/g, ".agents/skills/<handle>/*/` and `~/.agents/skills/<handle>/*/`")
|
|
40
|
+
.replace(/\.claude\/skills\/verify-<app>\/` \(`\.agents\/skills\/verify-<app>\/` on Codex\)/g, ".agents/skills/verify-<app>/`")
|
|
41
|
+
.replace(/`\.claude\/skills\/` \(`\.agents\/skills\/` on Codex\)/g, "`.agents/skills/`")
|
|
42
|
+
.replace(/usually `\.claude\/skills\/verify-\*\/`, or `\.agents\/skills\/verify-\*\/` on Codex/g, "usually `.agents/skills/verify-*/`")
|
|
43
|
+
.replace(/project `\.claude\/skills\/` or `\.agents\/skills\/`, user-level `~\/\.claude\/skills\/` or `~\/\.agents\/skills\/`, or plugin-installed paths under `~\/\.claude\/plugins\/`/g, "project `.agents/skills/` or user-level `~/.agents/skills/`")
|
|
44
|
+
.replace(/~\/\.claude\/skills\//g, "~/.agents/skills/")
|
|
45
|
+
.replace(/\.claude\/skills\//g, ".agents/skills/")
|
|
46
|
+
.replace(/\.claude\/worktrees\//g, ".codex/worktrees/")
|
|
47
|
+
.replace(/under `~\/\.claude\/projects\/<slug>\/`/g, `under ${CODEX_TRANSCRIPT}`)
|
|
48
|
+
.replace(/`environment: "cloud"`/g, "a cloud session only when Codex explicitly exposes one; otherwise use a local subagent")
|
|
49
|
+
.replace(/a real terminal `\/loop`/g, "Codex's available recurring-monitoring mechanism")
|
|
50
|
+
.replace(/the `\/loop` skill \(your harness's, not a pstack skill\)/g, "Codex's available recurring-monitoring or wait mechanism")
|
|
51
|
+
.replace(/under `\/loop` in dynamic mode/g, "with Codex's recurring-monitoring mechanism")
|
|
52
|
+
.replace(/`\/loop` per component/g, "repeat per component with the available monitoring mechanism")
|
|
53
|
+
.replace(/with the `\/loop` skill/g, "with Codex's available monitoring mechanism")
|
|
54
|
+
.replace(/\/loop/g, "a monitored loop")
|
|
55
|
+
.replace(/cloud-sleeper wake chain/g, "Codex long-running goal mechanism")
|
|
56
|
+
.replace(/monitored-shell 30-minute sleep and emits an output-notification sentinel/g, "recurring monitor with a 30-minute heartbeat")
|
|
57
|
+
.replace(/\/~\/\.claude\/CLAUDE\.md/g, "~/.codex/AGENTS.md")
|
|
58
|
+
.replace(/Claude Code/g, "Codex")
|
|
59
|
+
.replace(/pstack model config(?!uration)/g, "Codex pstack model config at `~/.codex/pstack-models.md`")
|
|
60
|
+
.replace(/\*\*Just do it\.\*\* Use any MCP tool\. Reversible work and external actions \(team chat, ticket updates, kicking off evals\) proceed without asking\./g, "**Respect the active authorization boundary.** Proceed with reversible local work. External writes, commits, pushes, PR changes, messages, and production actions require explicit scope and the host's approval rules.")
|
|
61
|
+
.replace(/- Broken skill mid-task → fix it in its own PR\. Don't block\. Don't silently work around it\./g, "- Broken skill mid-task → report and fix it locally when in scope. Open a separate PR only when the user authorized PR creation.")
|
|
62
|
+
.replace(/, and open a separate PR to update the configured value or default table/g, ", and report that the configured value needs updating")
|
|
63
|
+
.replace(/Commit it when stakes need an auditable record; keep it local otherwise\./g, "Keep it local unless the user explicitly authorized a commit.")
|
|
64
|
+
.replace(/Frontmatter `disable-model-invocation: true` by default\. Mode skills are heavy and opinionated; they should only apply when the user explicitly invokes them \(by name or slash command\), not auto-trigger on description matching\. Opt out only if the user explicitly wants their mode to apply on every turn\./g, "Add `agents/openai.yaml` with `policy.allow_implicit_invocation: false` by default. Mode skills are heavy and opinionated; they should apply only when the user explicitly invokes `$<name>`. Enable implicit invocation only when the user explicitly requests it.");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function adaptClaudeVocabulary(text) {
|
|
68
|
+
return text
|
|
69
|
+
.replace(CLAUDE_TRANSCRIPT_PARAGRAPH, `On Claude Code, transcripts live at ${CLAUDE_TRANSCRIPT}.`)
|
|
70
|
+
.replace(/\(`\.agents\/skills\/verify-<app>\/` on Codex\)/g, "")
|
|
71
|
+
.replace(/ \(`\.agents\/skills\/` on Codex\)/g, "")
|
|
72
|
+
.replace(/, or `\.agents\/skills\/verify-\*\/` on Codex/g, "")
|
|
73
|
+
.replace(/`\.claude\/skills\/` and `~\/\.claude\/skills\/` on Claude Code, `\.agents\/skills\/` and `~\/\.agents\/skills\/` on Codex/g, "`.claude/skills/` and `~/.claude/skills/`")
|
|
74
|
+
.replace(/project `\.claude\/skills\/` or `\.agents\/skills\/`, user-level `~\/\.claude\/skills\/` or `~\/\.agents\/skills\/`, or plugin-installed paths under `~\/\.claude\/plugins\/`/g, "project `.claude/skills/`, user-level `~/.claude/skills/`, or plugin-installed paths under `~/.claude/plugins/`")
|
|
75
|
+
.replace(/\. Every line is one chat message\. Scope to this workspace; never sweep the whole store, that reads private chats from unrelated projects/g, ". Scope to this workspace; never sweep unrelated projects")
|
|
76
|
+
.replace(/ \(`\.agents\/skills\/verify-<app>\/` on Codex\)/g, "")
|
|
77
|
+
.replace(/ \(`\.agents\/skills\/` on Codex\)/g, "");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function adaptRuntimeForHost(text, host) {
|
|
81
|
+
if (host === "claude") {
|
|
82
|
+
return text
|
|
83
|
+
.replace(/# Search only host-native transcript stores\. The worktree path match below keeps\n# Codex's global date-partitioned store scoped to this repository\./, "# Search only the Claude Code transcript store for this repository.")
|
|
84
|
+
.replace(/^\[ -d "\$HOME\/\.codex\/sessions" \].*\n/m, "");
|
|
85
|
+
}
|
|
86
|
+
return text
|
|
87
|
+
.replace(/# Search only host-native transcript stores\. The worktree path match below keeps\n# Codex's global date-partitioned store scoped to this repository\./, "# Search Codex's global transcript store and scope matches to this repository.")
|
|
88
|
+
.replace(/^slug=.*\n/m, "")
|
|
89
|
+
.replace(/^\[ -d "\$HOME\/\.claude\/projects\/\$slug" \].*\n/m, "");
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function adaptMarkdownForHost(text, { host, skillNames }) {
|
|
93
|
+
if (host === "claude") return adaptClaudeVocabulary(text);
|
|
94
|
+
let adapted = stripUnsupportedFrontmatter(text);
|
|
95
|
+
adapted = replaceSkillInvocations(adapted, skillNames);
|
|
96
|
+
adapted = adaptCodexVocabulary(adapted);
|
|
97
|
+
return adapted;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function writeCodexInvocationPolicy(skillDir, allowImplicitInvocation) {
|
|
101
|
+
const agentsDir = join(skillDir, "agents");
|
|
102
|
+
mkdirSync(agentsDir, { recursive: true });
|
|
103
|
+
writeFileSync(
|
|
104
|
+
join(agentsDir, "openai.yaml"),
|
|
105
|
+
`policy:\n allow_implicit_invocation: ${allowImplicitInvocation ? "true" : "false"}\n`,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function adaptCopiedSkillTree(skillDir, { host, skillNames, allowImplicitInvocation, nativeCodex = false }) {
|
|
110
|
+
const walk = (dir) => {
|
|
111
|
+
for (const entry of readdirSync(dir)) {
|
|
112
|
+
const path = join(dir, entry);
|
|
113
|
+
if (statSync(path).isDirectory()) {
|
|
114
|
+
walk(path);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
if (!path.endsWith(".md") && !path.endsWith("worktree-audit.sh")) continue;
|
|
118
|
+
const source = readFileSync(path, "utf8");
|
|
119
|
+
if (path.endsWith(".md")) {
|
|
120
|
+
writeFileSync(path, adaptMarkdownForHost(source, { host, skillNames }));
|
|
121
|
+
} else if (path.endsWith("worktree-audit.sh")) {
|
|
122
|
+
writeFileSync(path, adaptRuntimeForHost(source, host));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
if (!nativeCodex) walk(skillDir);
|
|
127
|
+
if (host === "codex") writeCodexInvocationPolicy(skillDir, allowImplicitInvocation);
|
|
128
|
+
}
|
package/scripts/lib.mjs
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { readdirSync, readFileSync, statSync, lstatSync, mkdirSync, rmSync, cpSync, existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { join, dirname, relative } from "node:path";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { adaptCopiedSkillTree } from "./host-adapters.mjs";
|
|
6
|
+
|
|
7
|
+
export const REPO_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
|
|
8
|
+
export const SKILLS_DIR = join(REPO_ROOT, "skills");
|
|
9
|
+
export const AGENTS_DIR = join(REPO_ROOT, "agents");
|
|
10
|
+
export const CODEX_ADAPTER_DIR = join(REPO_ROOT, "adapters", "codex");
|
|
11
|
+
export const CLAUDE_ADAPTER_DIR = join(REPO_ROOT, "adapters", "claude-code");
|
|
12
|
+
|
|
13
|
+
export const HOSTS = {
|
|
14
|
+
claude: {
|
|
15
|
+
label: "Claude Code",
|
|
16
|
+
skillsDir: (scope) => (scope === "project" ? join(process.cwd(), ".claude", "skills") : join(homedir(), ".claude", "skills")),
|
|
17
|
+
agentsDir: (scope) => (scope === "project" ? join(process.cwd(), ".claude", "agents") : join(homedir(), ".claude", "agents")),
|
|
18
|
+
memoryFile: (scope) => (scope === "project" ? join(process.cwd(), "CLAUDE.md") : join(homedir(), ".claude", "CLAUDE.md")),
|
|
19
|
+
invoke: (name) => `/${name}`,
|
|
20
|
+
},
|
|
21
|
+
codex: {
|
|
22
|
+
label: "Codex",
|
|
23
|
+
skillsDir: (scope) => (scope === "project" ? join(process.cwd(), ".agents", "skills") : join(homedir(), ".agents", "skills")),
|
|
24
|
+
agentsDir: (scope) => (scope === "project" ? join(process.cwd(), ".codex", "agents") : join(homedir(), ".codex", "agents")),
|
|
25
|
+
memoryFile: (scope) => (scope === "project" ? join(process.cwd(), "AGENTS.md") : join(homedir(), ".codex", "AGENTS.md")),
|
|
26
|
+
invoke: (name) => `$${name}`,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** Parse the `name` and `description` out of a SKILL.md's YAML frontmatter. */
|
|
31
|
+
export function parseFrontmatter(text) {
|
|
32
|
+
const m = /^---\r?\n([\s\S]*?)\r?\n---/.exec(text);
|
|
33
|
+
if (!m) return {};
|
|
34
|
+
const out = {};
|
|
35
|
+
// Only the two scalar fields pstack relies on; values may be quoted.
|
|
36
|
+
for (const key of ["name", "description"]) {
|
|
37
|
+
const km = new RegExp(`^${key}:[ \\t]*(.*)$`, "m").exec(m[1]);
|
|
38
|
+
if (!km) continue;
|
|
39
|
+
let v = km[1].trim();
|
|
40
|
+
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) {
|
|
41
|
+
v = v.slice(1, -1).replace(/\\"/g, '"');
|
|
42
|
+
}
|
|
43
|
+
out[key] = v;
|
|
44
|
+
}
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Every SKILL.md under skills/, including nested category dirs. */
|
|
49
|
+
export function findSkills(root = SKILLS_DIR) {
|
|
50
|
+
const found = [];
|
|
51
|
+
const walk = (dir) => {
|
|
52
|
+
for (const entry of readdirSync(dir)) {
|
|
53
|
+
const p = join(dir, entry);
|
|
54
|
+
if (!statSync(p).isDirectory()) continue;
|
|
55
|
+
const skillFile = join(p, "SKILL.md");
|
|
56
|
+
if (existsSync(skillFile)) {
|
|
57
|
+
const text = readFileSync(skillFile, "utf8");
|
|
58
|
+
const fm = parseFrontmatter(text);
|
|
59
|
+
found.push({
|
|
60
|
+
name: fm.name || entry,
|
|
61
|
+
dirName: entry,
|
|
62
|
+
description: fm.description || "",
|
|
63
|
+
path: p,
|
|
64
|
+
relPath: relative(root, p),
|
|
65
|
+
});
|
|
66
|
+
} else {
|
|
67
|
+
walk(p);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
walk(root);
|
|
72
|
+
return found.sort((a, b) => a.name.localeCompare(b.name));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Install one skill for a host.
|
|
77
|
+
* Nested category directories flatten to a single level, which is why build.mjs
|
|
78
|
+
* rejects duplicate directory names.
|
|
79
|
+
*/
|
|
80
|
+
export function installSkill(skill, { host, scope, dryRun = false }) {
|
|
81
|
+
const hostDir = HOSTS[host].skillsDir(scope);
|
|
82
|
+
const dest = join(hostDir, skill.dirName);
|
|
83
|
+
if (dryRun) return dest;
|
|
84
|
+
|
|
85
|
+
mkdirSync(hostDir, { recursive: true });
|
|
86
|
+
rmSync(dest, { recursive: true, force: true });
|
|
87
|
+
const adapterDir = host === "codex" ? CODEX_ADAPTER_DIR : CLAUDE_ADAPTER_DIR;
|
|
88
|
+
const override = join(adapterDir, "overrides", skill.dirName);
|
|
89
|
+
const source = existsSync(override) ? override : skill.path;
|
|
90
|
+
cpSync(source, dest, { recursive: true });
|
|
91
|
+
adaptCopiedSkillTree(dest, {
|
|
92
|
+
host,
|
|
93
|
+
skillNames: findSkills().map((item) => item.name),
|
|
94
|
+
allowImplicitInvocation: !readFileSync(join(skill.path, "SKILL.md"), "utf8").includes("disable-model-invocation: true"),
|
|
95
|
+
nativeCodex: source === override,
|
|
96
|
+
});
|
|
97
|
+
return dest;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function installAgents({ host, scope, dryRun = false }) {
|
|
101
|
+
const dir = HOSTS[host].agentsDir(scope);
|
|
102
|
+
const sourceDir = host === "codex" ? join(CODEX_ADAPTER_DIR, "agents") : AGENTS_DIR;
|
|
103
|
+
const extension = host === "codex" ? ".toml" : ".md";
|
|
104
|
+
if (!dir || !existsSync(sourceDir)) return null;
|
|
105
|
+
if (dryRun) return dir;
|
|
106
|
+
mkdirSync(dir, { recursive: true });
|
|
107
|
+
for (const f of readdirSync(sourceDir).filter((f) => f.endsWith(extension))) {
|
|
108
|
+
cpSync(join(sourceDir, f), join(dir, f));
|
|
109
|
+
}
|
|
110
|
+
return dir;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function expandSkillDependencies(selected, catalog = findSkills()) {
|
|
114
|
+
const selectedNames = new Set(selected.map((skill) => skill.name));
|
|
115
|
+
const queued = [...selected];
|
|
116
|
+
|
|
117
|
+
const readMarkdown = (dir) => {
|
|
118
|
+
let body = "";
|
|
119
|
+
for (const entry of readdirSync(dir)) {
|
|
120
|
+
const path = join(dir, entry);
|
|
121
|
+
if (statSync(path).isDirectory()) body += readMarkdown(path);
|
|
122
|
+
else if (path.endsWith(".md")) body += `\n${readFileSync(path, "utf8")}`;
|
|
123
|
+
}
|
|
124
|
+
return body;
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
while (queued.length) {
|
|
128
|
+
const current = queued.shift();
|
|
129
|
+
const body = readMarkdown(current.path);
|
|
130
|
+
for (const candidate of catalog) {
|
|
131
|
+
if (selectedNames.has(candidate.name)) continue;
|
|
132
|
+
const escaped = candidate.name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
133
|
+
if (!new RegExp(`(^|[^a-z0-9-])${escaped}([^a-z0-9-]|$)`, "i").test(body)) continue;
|
|
134
|
+
selectedNames.add(candidate.name);
|
|
135
|
+
queued.push(candidate);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return catalog.filter((skill) => selectedNames.has(skill.name));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** Installed pstack skills in one host dir, each tagged with whether it is a symlink. */
|
|
143
|
+
export function listInstalled({ host, scope }) {
|
|
144
|
+
const dir = HOSTS[host].skillsDir(scope);
|
|
145
|
+
if (!existsSync(dir)) return [];
|
|
146
|
+
const ours = new Set(findSkills().map((s) => s.dirName));
|
|
147
|
+
return readdirSync(dir)
|
|
148
|
+
.filter((d) => ours.has(d) && existsSync(join(dir, d, "SKILL.md")))
|
|
149
|
+
.map((d) => {
|
|
150
|
+
const p = join(dir, d);
|
|
151
|
+
let linkedTo = null;
|
|
152
|
+
try { if (lstatSync(p).isSymbolicLink()) linkedTo = realpathSync(p); } catch {}
|
|
153
|
+
return { name: d, path: p, linkedTo };
|
|
154
|
+
})
|
|
155
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Remove a skill from one host. lstat, not exists, so a symlink left dangling by an
|
|
160
|
+
* earlier removal still gets cleared.
|
|
161
|
+
*/
|
|
162
|
+
export function removeSkill(dirName, { host, scope, dryRun = false }) {
|
|
163
|
+
const dest = join(HOSTS[host].skillsDir(scope), dirName);
|
|
164
|
+
try { lstatSync(dest); } catch { return null; }
|
|
165
|
+
if (!dryRun) rmSync(dest, { recursive: true, force: true });
|
|
166
|
+
return dest;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** The curated entry set. Installation expands its transitive skill references. */
|
|
170
|
+
export const CORE_SKILLS = [
|
|
171
|
+
"poteto-mode",
|
|
172
|
+
"setup-pstack",
|
|
173
|
+
"how",
|
|
174
|
+
"why",
|
|
175
|
+
"architect",
|
|
176
|
+
"interrogate",
|
|
177
|
+
"unslop",
|
|
178
|
+
"no-comments",
|
|
179
|
+
"technical-writing",
|
|
180
|
+
"tdd",
|
|
181
|
+
];
|
package/scripts/test.mjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { spawnSync } from "node:child_process";
|
|
4
|
+
import {
|
|
5
|
+
existsSync,
|
|
6
|
+
lstatSync,
|
|
7
|
+
mkdtempSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
readdirSync,
|
|
10
|
+
rmSync,
|
|
11
|
+
statSync,
|
|
12
|
+
} from "node:fs";
|
|
13
|
+
import { tmpdir } from "node:os";
|
|
14
|
+
import { dirname, join } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
import {
|
|
17
|
+
CORE_SKILLS,
|
|
18
|
+
REPO_ROOT,
|
|
19
|
+
expandSkillDependencies,
|
|
20
|
+
findSkills,
|
|
21
|
+
installAgents,
|
|
22
|
+
installSkill,
|
|
23
|
+
} from "./lib.mjs";
|
|
24
|
+
|
|
25
|
+
const scriptsDir = dirname(fileURLToPath(import.meta.url));
|
|
26
|
+
const check = spawnSync(process.execPath, [join(scriptsDir, "build.mjs")], {
|
|
27
|
+
encoding: "utf8",
|
|
28
|
+
});
|
|
29
|
+
assert.equal(check.status, 0, check.stderr || check.stdout);
|
|
30
|
+
|
|
31
|
+
const shellCheck = spawnSync("bash", ["-n", join(REPO_ROOT, "skills", "poteto-mode", "scripts", "worktree-audit.sh")], {
|
|
32
|
+
encoding: "utf8",
|
|
33
|
+
});
|
|
34
|
+
assert.equal(shellCheck.status, 0, shellCheck.stderr || shellCheck.stdout);
|
|
35
|
+
|
|
36
|
+
const planCheck = spawnSync(process.execPath, ["--check", join(REPO_ROOT, "skills", "poteto-mode", "scripts", "check-plan.mjs")], {
|
|
37
|
+
encoding: "utf8",
|
|
38
|
+
});
|
|
39
|
+
assert.equal(planCheck.status, 0, planCheck.stderr || planCheck.stdout);
|
|
40
|
+
|
|
41
|
+
const testRoot = mkdtempSync(join(tmpdir(), "pstack-host-isolation-"));
|
|
42
|
+
const originalCwd = process.cwd();
|
|
43
|
+
|
|
44
|
+
function markdownUnder(root) {
|
|
45
|
+
const files = [];
|
|
46
|
+
const walk = (dir) => {
|
|
47
|
+
for (const entry of readdirSync(dir)) {
|
|
48
|
+
const path = join(dir, entry);
|
|
49
|
+
if (statSync(path).isDirectory()) walk(path);
|
|
50
|
+
else if (path.endsWith(".md")) files.push(path);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
walk(root);
|
|
54
|
+
return files;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
process.chdir(testRoot);
|
|
59
|
+
const catalog = findSkills();
|
|
60
|
+
const requested = catalog.filter((skill) => CORE_SKILLS.includes(skill.name));
|
|
61
|
+
const selected = expandSkillDependencies(requested, catalog);
|
|
62
|
+
assert(selected.length > requested.length, "core entries must expand their skill dependencies");
|
|
63
|
+
|
|
64
|
+
for (const host of ["claude", "codex"]) {
|
|
65
|
+
for (const skill of selected) installSkill(skill, { host, scope: "project" });
|
|
66
|
+
installAgents({ host, scope: "project" });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const claudeRoot = join(testRoot, ".claude", "skills");
|
|
70
|
+
const codexRoot = join(testRoot, ".agents", "skills");
|
|
71
|
+
const claudeMode = join(claudeRoot, "poteto-mode", "SKILL.md");
|
|
72
|
+
const codexMode = join(codexRoot, "poteto-mode", "SKILL.md");
|
|
73
|
+
|
|
74
|
+
assert(!lstatSync(join(claudeRoot, "poteto-mode")).isSymbolicLink());
|
|
75
|
+
assert(!lstatSync(join(codexRoot, "poteto-mode")).isSymbolicLink());
|
|
76
|
+
assert.notEqual(statSync(claudeMode).ino, statSync(codexMode).ino);
|
|
77
|
+
assert(existsSync(join(testRoot, ".claude", "agents", "comment-sicko.md")));
|
|
78
|
+
assert(existsSync(join(testRoot, ".codex", "agents", "comment-sicko.toml")));
|
|
79
|
+
assert(existsSync(join(codexRoot, "poteto-mode", "agents", "openai.yaml")));
|
|
80
|
+
|
|
81
|
+
const claudeAudit = readFileSync(join(claudeRoot, "poteto-mode", "scripts", "worktree-audit.sh"), "utf8");
|
|
82
|
+
const codexAudit = readFileSync(join(codexRoot, "poteto-mode", "scripts", "worktree-audit.sh"), "utf8");
|
|
83
|
+
assert.doesNotMatch(claudeAudit, /\.codex\/sessions/);
|
|
84
|
+
assert.doesNotMatch(codexAudit, /\.claude\/projects/);
|
|
85
|
+
|
|
86
|
+
for (const path of markdownUnder(claudeRoot)) {
|
|
87
|
+
const body = readFileSync(path, "utf8");
|
|
88
|
+
assert(!/\.codex\/|\.agents\/skills|\$[a-z][a-z0-9-]+/.test(body), `Codex leak in ${path}`);
|
|
89
|
+
}
|
|
90
|
+
for (const path of markdownUnder(codexRoot)) {
|
|
91
|
+
const body = readFileSync(path, "utf8");
|
|
92
|
+
assert(!/\.claude\/|Claude Code|Task tool|subagent_type:|run_in_background|AskQuestion/.test(body), `Claude leak in ${path}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const claudeSetup = readFileSync(join(claudeRoot, "setup-pstack", "SKILL.md"), "utf8");
|
|
96
|
+
const codexSetup = readFileSync(join(codexRoot, "setup-pstack", "SKILL.md"), "utf8");
|
|
97
|
+
assert.match(claudeSetup, /~\/\.claude\/pstack-models\.md/);
|
|
98
|
+
assert.match(codexSetup, /~\/\.codex\/pstack-models\.md/);
|
|
99
|
+
assert.doesNotMatch(claudeSetup, /~\/\.codex/);
|
|
100
|
+
assert.doesNotMatch(codexSetup, /~\/\.claude/);
|
|
101
|
+
} finally {
|
|
102
|
+
process.chdir(originalCwd);
|
|
103
|
+
rmSync(testRoot, { recursive: true, force: true });
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
console.log("host isolation and installation checks passed");
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: architect
|
|
3
|
+
description: "Sketch types, signatures, and module structure before code, then stay in the loop while implementation fills in. Use for /architect, 'architect this', 'design this', or non-trivial work where jumping to code would lock in the wrong shape."
|
|
4
|
+
disable-model-invocation: true
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Architect
|
|
8
|
+
|
|
9
|
+
Design before implementing. Sketch types, function signatures, class shapes, and module boundaries with `not implemented` bodies and pseudocode. Synthesize across multiple model perspectives, then fill in code against the chosen sketch. If implementation proves the sketch wrong, throw it out and redesign.
|
|
10
|
+
|
|
11
|
+
## Start
|
|
12
|
+
|
|
13
|
+
Open a todolist with one entry per phase before starting. Autonomous mode without checkpoints needs the list to show phase position and keep phases from silently disappearing.
|
|
14
|
+
|
|
15
|
+
1. Ground
|
|
16
|
+
2. Sketch
|
|
17
|
+
3. Agree
|
|
18
|
+
4. Implement
|
|
19
|
+
5. Scrap
|
|
20
|
+
|
|
21
|
+
## Phase A: Ground the problem
|
|
22
|
+
|
|
23
|
+
Build a real mental model of every system the new code touches. Run the **how** skill over the relevant subsystems. Critique mode if existing structure is the constraint or the design must push back on it.
|
|
24
|
+
|
|
25
|
+
Naming a file isn't grounding. Produce the traced model `how` prescribes. If the design redefines ownership or layering, also run the **why** skill on the existing shape so the rationale becomes a constraint, not a guess.
|
|
26
|
+
|
|
27
|
+
Skip Phase A only when the work is genuinely greenfield with no surrounding system to integrate.
|
|
28
|
+
|
|
29
|
+
## Phase B: Sketch
|
|
30
|
+
|
|
31
|
+
Run the **arena** skill with the design-sketch task and the Phase A grounding artifacts. Pass `references/runner-prompt.md` as each runner's prompt. Each candidate produces a design package shaped per `references/rationale-template.md`: the caller's usage written first, then the type sketch, function signatures, module map, and prose rationale derived from it.
|
|
32
|
+
|
|
33
|
+
Use your configured architect runners (defaults to one on each of your judgment, precise-execution, and fast code models).
|
|
34
|
+
|
|
35
|
+
Design it twice. Require at least two structurally distinct candidates before synthesis, even when the first looks sufficient. This is the **exhaust-the-design-space** principle skill made concrete. Whole-shape alternatives, not point fixes inside one shape.
|
|
36
|
+
|
|
37
|
+
Screen every candidate against [`references/design-red-flags.md`](references/design-red-flags.md) before synthesis. Reject or revise shallow modules, information leakage, temporal decomposition, and pass-through methods.
|
|
38
|
+
|
|
39
|
+
Compare viable candidates on interface depth. Prefer the design that hides more complexity behind a smaller, simpler public surface. A rich interface can keep call chains short by concentrating capability instead of scattering it across layers.
|
|
40
|
+
|
|
41
|
+
Arena returns one synthesized design package. The synthesis decision populates the rationale's "Synthesis decision" section.
|
|
42
|
+
|
|
43
|
+
## Phase C: Agree (opt-in)
|
|
44
|
+
|
|
45
|
+
Default: proceed directly to implementation with the synthesized design. No human checkpoint.
|
|
46
|
+
|
|
47
|
+
Opt in to a checkpoint when the invoker explicitly asks: "/architect with checkpoint," "stop and show me before implementing," or similar. Then surface the synthesized design and pause for sign-off.
|
|
48
|
+
|
|
49
|
+
The synthesis can ship as its own commit either way. That's the "scaffold first" mode of the **foundational-thinking** principle skill; subsequent commits read as filling in bodies against a stable contract. Planned and scoped breakage during fill-in is fine, per the **outcome-oriented-execution** principle skill. For adversarial pressure on the design before implementing, run the **interrogate** skill on the synthesized sketch.
|
|
50
|
+
|
|
51
|
+
If the human pushes back on the shape (in a checkpoint or after the fact), treat that as Phase A evidence. Re-ground and re-run Phase B before writing more code.
|
|
52
|
+
|
|
53
|
+
## Phase D: Implement against the sketch
|
|
54
|
+
|
|
55
|
+
Replace `not implemented` bodies with code, pseudocode with logic. The synthesized sketch is the contract.
|
|
56
|
+
|
|
57
|
+
Deviations from the sketch are signal worth surfacing, not friction to absorb silently. If a function needs a parameter the sketch didn't anticipate, ask whether the sketch was wrong, the requirement was missed, or the implementation is overreaching. Surface it; don't bolt it on.
|
|
58
|
+
|
|
59
|
+
## Phase E: Scrap when the architecture is wrong
|
|
60
|
+
|
|
61
|
+
If implementation keeps producing friction the sketch can't absorb, throw the sketch out. Don't bolt fixes onto a wrong design, per the **redesign-from-first-principles** and **fix-root-causes** principle skills.
|
|
62
|
+
|
|
63
|
+
The signal is a *pattern*, not single instances. Tells:
|
|
64
|
+
|
|
65
|
+
- The same shape of workaround appearing repeatedly across unrelated code.
|
|
66
|
+
- Multiple unrelated edge cases that all need special-case branches.
|
|
67
|
+
- Types that need escape hatches (`any`, casts, optional fields always set in practice) to compile.
|
|
68
|
+
- The "we need a lock" reflex when the sketch said the state wasn't shared.
|
|
69
|
+
- Callers having to know the abstraction's internal rules to use it.
|
|
70
|
+
- Two or more independent Phase D deviations of the same shape across the implementation. Surfacing deviations is Phase D's job; a repeated pattern of them is Phase E's trigger.
|
|
71
|
+
|
|
72
|
+
Use judgment. A few edge cases don't condemn an architecture. Some problems are legitimately complex; complexity in the data is not complexity in the design. The rewrite signal is repeated friction of the same shape, not single hard cases.
|
|
73
|
+
|
|
74
|
+
When you scrap:
|
|
75
|
+
|
|
76
|
+
1. Re-run the **how** skill over what's been built. The implementation lessons enter the new design as inputs, not vibes.
|
|
77
|
+
2. Redesign as if the new constraints had been day-one assumptions, per redesign-from-first-principles.
|
|
78
|
+
3. Subtract before adding, per the **subtract-before-you-add** principle skill. The new sketch should be smaller than the old one before it grows.
|
|
79
|
+
4. Return to Phase B and re-run arena.
|
|
80
|
+
|
|
81
|
+
## Outputs
|
|
82
|
+
|
|
83
|
+
The caller's usage is written first and the type sketch derived from it. One file with new types and signatures for small changes; module map plus type definitions for larger work. The rationale ships alongside, shaped per `references/rationale-template.md`, including the usage sketch and the synthesis decision.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Design red flags
|
|
2
|
+
|
|
3
|
+
Screen every candidate before synthesis. A red flag is a reason to revise or reject the shape.
|
|
4
|
+
|
|
5
|
+
## Shallow module
|
|
6
|
+
|
|
7
|
+
A shallow module exposes a large interface while hiding little complexity. Judge depth by the capability and policy hidden behind the public surface relative to the size of that surface. Prefer a simple interface backed by substantial behavior.
|
|
8
|
+
|
|
9
|
+
Do not confuse a deep module with a deep call chain. A deep call chain scatters understanding across layers. A deep module concentrates capability behind one interface.
|
|
10
|
+
|
|
11
|
+
Look for these signs:
|
|
12
|
+
|
|
13
|
+
- Callers coordinate several methods to complete one operation.
|
|
14
|
+
- Public options expose internal stages or implementation choices.
|
|
15
|
+
- Learning the interface does not save the caller from learning the implementation.
|
|
16
|
+
|
|
17
|
+
## Information leakage
|
|
18
|
+
|
|
19
|
+
Information leakage makes multiple modules depend on the same internal decision. A representation, policy, or protocol detail appears in more than one place, so changing it requires coordinated edits.
|
|
20
|
+
|
|
21
|
+
Public re-exports of transport or wire types are leakage. Parse external data into domain types behind the interface. Keep storage schemas, framework objects, and protocol details private.
|
|
22
|
+
|
|
23
|
+
## Temporal decomposition
|
|
24
|
+
|
|
25
|
+
Temporal decomposition organizes modules by execution order instead of the knowledge they own. Separate load, validate, transform, and save stages often repeat one representation and its invariants across several boundaries.
|
|
26
|
+
|
|
27
|
+
Group code around domain knowledge and ownership. Methods that run at different times can still belong to one module when they protect the same decisions.
|
|
28
|
+
|
|
29
|
+
## Pass-through method
|
|
30
|
+
|
|
31
|
+
A pass-through method forwards the same arguments to another method with the same shape. It adds a layer without hiding complexity.
|
|
32
|
+
|
|
33
|
+
Remove it or move responsibility to the module that can complete the operation. Keep a forwarding boundary only when it adds policy, adaptation, or a distinct abstraction.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Rationale template
|
|
2
|
+
|
|
3
|
+
The prose that ships alongside the type sketch. One page. Sentence-case headings, no boilerplate. Replace the italic notes with actual content.
|
|
4
|
+
|
|
5
|
+
## Problem
|
|
6
|
+
|
|
7
|
+
*One paragraph. What we're trying to do, and what about the existing system or constraints makes the shape non-obvious. If [Phase A](../SKILL.md#phase-a-ground-the-problem) surfaced constraints the design must honor (existing types to interop with, callers we can't break, invariants that crossed our boundary), name them here so the reader sees the same constraints you saw.*
|
|
8
|
+
|
|
9
|
+
## Usage (caller's view)
|
|
10
|
+
|
|
11
|
+
*Write this first, before the type sketch. Show the README or quickstart the consumer reads, plus two or three realistic call sites in their own code. What they import, what they call, what comes back. The type sketch in [Shape](#shape) is derived from this. The two must agree; when they diverge, reconcile the sketch to the usage, not the reverse. The caller's experience is the spec. The types serve it.*
|
|
12
|
+
|
|
13
|
+
## Shape
|
|
14
|
+
|
|
15
|
+
*The recommended architecture. Data structures first; then how data flows through the signatures. Name the load-bearing decisions. State which invariants are encoded in types, where validation lives, and what the system deliberately does not do. Judge interface depth explicitly. State what complexity the public surface hides, what remains exposed to callers, and why the interface is no larger than needed. Cite the principle behind each decision (e.g., `per boundary-discipline`); don't restate it.*
|
|
16
|
+
|
|
17
|
+
## Synthesis decision
|
|
18
|
+
|
|
19
|
+
*Filled in by [arena](../../arena/SKILL.md). Records which candidate became the base and why, what was adapted from each of the others, and what was rejected and why.*
|
|
20
|
+
|
|
21
|
+
## Tradeoffs accepted
|
|
22
|
+
|
|
23
|
+
*One bullet per tradeoff the chosen shape makes. Form: "we accept X in exchange for Y." Name anything a future reader might mistake for an oversight, including things that look like premature optimization or premature simplification.*
|
|
24
|
+
|
|
25
|
+
## Alternatives considered
|
|
26
|
+
|
|
27
|
+
*Required. Name at least one concrete alternative shape, with one line on why it lost. Judge each alternative on interface depth, not implementation simplicity alone. Name the complexity it exposes to callers and the complexity it hides. Two or three alternatives belong here when the design space had real contenders. One is fine when the constraints forced the answer, with the conclusion phrased as "this was the only viable shape because..." Avoid listing flavors of the same shape. This section covers design alternatives the chosen shape considered and rejected, not other runner candidates.*
|
|
28
|
+
|
|
29
|
+
## Open questions and risks
|
|
30
|
+
|
|
31
|
+
*Things you noticed during the sketch that the human needs to weigh in on, and risks worth flagging before implementation starts. Phrase as questions, not assertions, so the human's answer is the resolution rather than a comment.*
|
|
32
|
+
|
|
33
|
+
## Next implementation step
|
|
34
|
+
|
|
35
|
+
*The first thing to build against the sketch. One sentence. What you'd start writing immediately after synthesis (or after Phase D sign-off, if a checkpoint was opted into).*
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Architect runner prompt
|
|
2
|
+
|
|
3
|
+
The orchestrator passes this file through to every parallel candidate runner during Phase B and fills in the variable inputs around it: the task, the Phase A grounding artifacts, the isolated working directory, and the path to write outputs. The working directory is a git worktree when available, otherwise a per-runner subdirectory under the sketch dir; what matters is independence between candidates.
|
|
4
|
+
|
|
5
|
+
You are producing one candidate design in architect's parallel exploration. Read the **architect** skill in full first; that's the workflow you're inside. Output a candidate design package: type sketch, function signatures, module map, and prose rationale shaped per [`rationale-template.md`](rationale-template.md).
|
|
6
|
+
|
|
7
|
+
Apply the following discipline. The orchestrator compares candidates on these axes to pick a base.
|
|
8
|
+
|
|
9
|
+
- Caller's usage first. Write the README-style usage and two or three real call sites before the types, then derive the type sketch from them. The usage is the spec; the two must agree, so reconcile the sketch to the usage, not the reverse.
|
|
10
|
+
- Data structures first. Get the core types right and the code becomes obvious. Trace each dominant access pattern through the proposed structure; if the answer is "we'll add a map / index / cache later," the structure is wrong.
|
|
11
|
+
- Interface depth. Compare the capability hidden behind the public surface relative to the size of that surface. Prefer a simple interface that pulls complexity into the callee, even when the implementation becomes less simple. Do not put transport or wire types on the public surface; parse into domain types behind the interface.
|
|
12
|
+
- Shared state: if two actors might both write, ask "what happens?" If the answer isn't "nothing," default to per-actor state with a merge at the read boundary, per the **separate-before-serializing-shared-state** principle skill.
|
|
13
|
+
- Make boundaries visible. `not implemented` errors for bodies, `// TODO` pseudocode for tricky logic, doc comments stating intent and invariants. A reader should trace data from input to output by reading types and signatures alone.
|
|
14
|
+
- Encode invariants in types: hard-to-misuse types > runtime checks > prose comments, per the **encode-lessons-in-structure** principle skill.
|
|
15
|
+
- Validate at boundaries, trust types inside, per the **boundary-discipline** principle skill. Business logic as pure functions; the shell stays thin.
|
|
16
|
+
- Single source of truth per invariant. Derive instead of sync.
|
|
17
|
+
- Idempotent state transitions where applicable, per the **make-operations-idempotent** principle skill. Ask what happens if the operation runs twice or crashes halfway.
|
|
18
|
+
- Short call chains. If tracing the flow needs more than three files, flatten the hierarchy, per the **laziness-protocol** and **minimize-reader-load** principle skills.
|
|
19
|
+
|
|
20
|
+
You are one of several runners, each on a different model. Produce the best design your model can make; don't hedge against the others. Differences between candidates are the signal used to pick a base and graft. Converging on a safe-looking middle defeats the exploration.
|