phronesis 1.0.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 (142) hide show
  1. package/README.md +66 -0
  2. package/package.json +34 -0
  3. package/src/act.js +61 -0
  4. package/src/active-context.js +56 -0
  5. package/src/adapter.js +386 -0
  6. package/src/cli.js +1893 -0
  7. package/src/codex-hooks-schema.js +92 -0
  8. package/src/compile.js +513 -0
  9. package/src/doctor.js +303 -0
  10. package/src/due.js +271 -0
  11. package/src/eval.js +467 -0
  12. package/src/event.js +212 -0
  13. package/src/export.js +136 -0
  14. package/src/guard.js +89 -0
  15. package/src/hooks.js +230 -0
  16. package/src/ingest.js +965 -0
  17. package/src/init.js +150 -0
  18. package/src/layout.js +394 -0
  19. package/src/links.js +83 -0
  20. package/src/lint.js +58 -0
  21. package/src/profile.js +116 -0
  22. package/src/prompts.js +26 -0
  23. package/src/registry.js +190 -0
  24. package/src/scaffold.js +134 -0
  25. package/src/search.js +139 -0
  26. package/src/skill-discovery.js +117 -0
  27. package/src/skills-bump.js +885 -0
  28. package/src/skills.js +355 -0
  29. package/src/subscription.js +5 -0
  30. package/src/validate.js +152 -0
  31. package/templates/claude/settings.json +86 -0
  32. package/templates/codex/INDEX.md +68 -0
  33. package/templates/codex/seed/ai-practice/compile-dont-just-capture.md +42 -0
  34. package/templates/codex/seed/ai-practice/design-for-the-distribution.md +42 -0
  35. package/templates/codex/seed/ai-practice/from-spec-author-to-outcome-curator.md +43 -0
  36. package/templates/codex/seed/ai-practice/recall-builds-trust-when-calibrated.md +70 -0
  37. package/templates/codex/seed/ai-practice/the-eval-is-the-spec.md +42 -0
  38. package/templates/codex/seed/ai-practice/the-gold-dust-leaves-no-trace.md +72 -0
  39. package/templates/codex/seed/ai-practice/the-model-is-not-the-moat.md +40 -0
  40. package/templates/codex/seed/ai-practice/when-generation-is-cheap-judgment-is-the-work.md +39 -0
  41. package/templates/codex/seed/judgment/contextual-stewardship-is-the-senior-skill.md +50 -0
  42. package/templates/codex/seed/judgment/decision-quality-is-distinct-from-outcome-quality.md +39 -0
  43. package/templates/codex/seed/judgment/embrace-reality-ego-and-blind-spots.md +38 -0
  44. package/templates/codex/seed/judgment/groups-seek-consensus-individuals-seek-truth.md +44 -0
  45. package/templates/codex/seed/judgment/heresies-are-where-the-edge-lives.md +42 -0
  46. package/templates/codex/seed/judgment/judgment-compounds-through-honest-reflection.md +38 -0
  47. package/templates/codex/seed/judgment/phronesis-is-judgment-in-the-particular.md +67 -0
  48. package/templates/codex/seed/judgment/show-me-the-apparatus.md +40 -0
  49. package/templates/codex/seed/judgment/small-judgment-gaps-compound-under-leverage.md +37 -0
  50. package/templates/codex/seed/judgment/taste-is-compressed-judgment.md +38 -0
  51. package/templates/codex/seed/judgment/trust-taste-only-where-feedback-is-valid.md +42 -0
  52. package/templates/codex/seed/judgment/weigh-the-reasoning-not-the-recommendation.md +43 -0
  53. package/templates/codex/seed/leadership/a-managers-output-is-the-teams-output.md +35 -0
  54. package/templates/codex/seed/leadership/most-team-problems-are-structural.md +40 -0
  55. package/templates/codex/seed/leadership/next-play.md +36 -0
  56. package/templates/codex/seed/leadership/psychological-safety.md +39 -0
  57. package/templates/codex/seed/leadership/right-size-your-teams.md +38 -0
  58. package/templates/codex/seed/leadership/spend-time-on-high-leverage-activities.md +36 -0
  59. package/templates/codex/seed/leadership/talent-density-is-the-master-variable.md +39 -0
  60. package/templates/codex/seed/leadership/under-pressure-calm-is-contagious.md +36 -0
  61. package/templates/codex/seed/leadership/your-best-alternative-is-your-leverage.md +37 -0
  62. package/templates/codex/seed/pm/a-problem-well-stated-is-half-solved.md +39 -0
  63. package/templates/codex/seed/pm/a-real-strategy-makes-planning-trivial.md +40 -0
  64. package/templates/codex/seed/pm/barrels-and-ammunition.md +39 -0
  65. package/templates/codex/seed/pm/develop-taste-in-your-beliefs.md +38 -0
  66. package/templates/codex/seed/pm/hire-for-progress.md +44 -0
  67. package/templates/codex/seed/pm/jobs-are-stable-solutions-churn.md +39 -0
  68. package/templates/codex/seed/pm/level-by-the-ambiguity-someone-can-own.md +39 -0
  69. package/templates/codex/seed/pm/listen-before-you-prescribe.md +38 -0
  70. package/templates/codex/seed/pm/live-in-the-future-and-build-whats-missing.md +38 -0
  71. package/templates/codex/seed/pm/match-effort-to-leverage.md +37 -0
  72. package/templates/codex/seed/pm/not-my-fault-but-my-problem.md +40 -0
  73. package/templates/codex/seed/pm/pick-the-job-then-refuse-everything-outside-it.md +37 -0
  74. package/templates/codex/seed/pm/retention-sets-the-ceiling.md +38 -0
  75. package/templates/codex/seed/pm/scale-with-leaders-not-process.md +38 -0
  76. package/templates/codex/seed/pm/solution-discovery-over-problem-validation.md +38 -0
  77. package/templates/codex/seed/pm/tenfold-better-on-a-painful-problem.md +40 -0
  78. package/templates/codex-surface/README.md +73 -0
  79. package/templates/codex-surface/hooks/_resolve.sh +36 -0
  80. package/templates/codex-surface/hooks/recall-guard.sh +30 -0
  81. package/templates/codex-surface/hooks/session-start.sh +18 -0
  82. package/templates/codex-surface/hooks/session-sweep-precompact.sh +20 -0
  83. package/templates/codex-surface/hooks/session-sweep-subagent.sh +23 -0
  84. package/templates/codex-surface/hooks/session-sweep.sh +19 -0
  85. package/templates/codex-surface/hooks.json +69 -0
  86. package/templates/domains/pm/AGENTS.md +111 -0
  87. package/templates/domains/pm/MEMORY.md +7 -0
  88. package/templates/domains/pm/USER.md +8 -0
  89. package/templates/phronesis-hooks/compile-active-context.sh +38 -0
  90. package/templates/phronesis-hooks/recall-guard.sh +103 -0
  91. package/templates/phronesis-hooks/session-start.sh +90 -0
  92. package/templates/phronesis-hooks/session-sweep.sh +140 -0
  93. package/templates/phronesis-hooks/skill-lifecycle.sh +37 -0
  94. package/templates/skills/compile/SKILL.md +279 -0
  95. package/templates/skills/compile/evals/rubric.md +75 -0
  96. package/templates/skills/decision-log/SKILL.md +156 -0
  97. package/templates/skills/decision-log/evals/rubric.md +97 -0
  98. package/templates/skills/extract-gold-dust/SKILL.md +311 -0
  99. package/templates/skills/extract-gold-dust/evals/rubric.md +52 -0
  100. package/templates/skills/ingest/SKILL.md +204 -0
  101. package/templates/skills/ingest/evals/rubric.md +117 -0
  102. package/templates/skills/lint/SKILL.md +246 -0
  103. package/templates/skills/lint/evals/rubric.md +139 -0
  104. package/templates/skills/meeting-prep/SKILL.md +195 -0
  105. package/templates/skills/meeting-prep/evals/rubric.md +93 -0
  106. package/templates/skills/onboard/SKILL.md +258 -0
  107. package/templates/skills/onboard/evals/rubric.md +60 -0
  108. package/templates/skills/prd-draft/SKILL.md +193 -0
  109. package/templates/skills/prd-draft/evals/rubric.md +38 -0
  110. package/templates/skills/prep-extraction/SKILL.md +217 -0
  111. package/templates/skills/prep-extraction/evals/rubric.md +45 -0
  112. package/templates/skills/recall/SKILL.md +155 -0
  113. package/templates/skills/recall/evals/rubric.md +37 -0
  114. package/templates/skills/research/SKILL.md +247 -0
  115. package/templates/skills/research/evals/rubric.md +139 -0
  116. package/templates/skills/stakeholder-update/SKILL.md +163 -0
  117. package/templates/skills/stakeholder-update/evals/rubric.md +111 -0
  118. package/vendor/core/package.json +25 -0
  119. package/vendor/core/src/action-registry.js +459 -0
  120. package/vendor/core/src/action-writers.js +201 -0
  121. package/vendor/core/src/actions.js +2140 -0
  122. package/vendor/core/src/active-context.js +167 -0
  123. package/vendor/core/src/artifacts.js +301 -0
  124. package/vendor/core/src/content-digest.js +21 -0
  125. package/vendor/core/src/contract.js +245 -0
  126. package/vendor/core/src/event-log.js +338 -0
  127. package/vendor/core/src/guard.js +398 -0
  128. package/vendor/core/src/hook-executor.js +527 -0
  129. package/vendor/core/src/index.js +180 -0
  130. package/vendor/core/src/ingest.js +286 -0
  131. package/vendor/core/src/install-root.js +42 -0
  132. package/vendor/core/src/layout.js +13 -0
  133. package/vendor/core/src/link-index.js +198 -0
  134. package/vendor/core/src/lint.js +368 -0
  135. package/vendor/core/src/schedule.js +535 -0
  136. package/vendor/core/src/search.js +534 -0
  137. package/vendor/core/src/session-hooks.js +129 -0
  138. package/vendor/core/src/skill-lifecycle.js +479 -0
  139. package/vendor/core/src/skill-registry.js +524 -0
  140. package/vendor/core/src/subscription.js +84 -0
  141. package/vendor/core/src/validate-object.js +62 -0
  142. package/vendor/core/src/workspace-scan.js +125 -0
@@ -0,0 +1,125 @@
1
+ // Workspace scan — the single source for "what is a typed object in a Phronesis
2
+ // installation, and how do we find and read it." Shared by `phronesis validate`
3
+ // (core-0004 / T2.1) and the link index + walk (core-0005 / T2.3); extracted to
4
+ // packages/core (core-0007) so the action types (T2.2) get the same discovery.
5
+ //
6
+ // These three primitives encode the drift-prone half of the ontology contract — file
7
+ // discovery, frontmatter splitting, and path→context (which folder means which layer /
8
+ // type-dir). Keeping them in one module is what lets the validator and the link index
9
+ // never disagree about what counts as an object or where a link target resolves.
10
+
11
+ import { join, relative, basename, sep } from 'node:path';
12
+ import { readdir, readFile } from 'node:fs/promises';
13
+ import yaml from 'js-yaml';
14
+
15
+ // THE answer to "where does a frontmatter block start and end" — one regex, two
16
+ // consumers (the validator's splitFrontmatter and the RMW writers' splitObjectSource).
17
+ // A second regex answering the same structural question is drift waiting to fire: the
18
+ // core-0009 adversarial review reproduced validator-green files (a `--- ` closing fence
19
+ // with a trailing space; an inner `--- ` line) that a stricter sibling regex refused or
20
+ // mis-split. The closing fence tolerates same-line trailing whitespace and consumes
21
+ // exactly ONE newline, so a body's leading blank line stays with the body (the RMW
22
+ // writers carry the body over byte-for-byte).
23
+ const FRONTMATTER_BLOCK_RE = /^---\r?\n([\s\S]*?)\r?\n---[^\S\r\n]*(?:\r?\n|$)/;
24
+
25
+ export function matchFrontmatterBlock(content) {
26
+ return content.match(FRONTMATTER_BLOCK_RE);
27
+ }
28
+
29
+ // Split a leading `---\n…\n---` YAML frontmatter block. Returns the YAML source, or
30
+ // null if the file has no frontmatter block.
31
+ export function splitFrontmatter(content) {
32
+ const m = matchFrontmatterBlock(content);
33
+ return m ? m[1] : null;
34
+ }
35
+
36
+ // Read + parse one typed-object file into { rel, ctx, fm, body }, or null for anything
37
+ // that is not a parseable typed object (no frontmatter, broken YAML, non-object YAML,
38
+ // not an object path). ONE parse implementation for every consumer that turns a file
39
+ // into an object record — the link index's disk pass and the search snapshot
40
+ // (core-0014) both ride this; a re-typed sibling parse (its own yaml options, its own
41
+ // shape checks) is the same drift class as a re-typed frontmatter regex (the core-0009
42
+ // lesson, one level up).
43
+ export async function readObjectRecord(root, rel) {
44
+ const ctx = contextFor(rel);
45
+ if (!ctx) return null;
46
+ let content;
47
+ try {
48
+ content = await readFile(join(root, rel), 'utf8');
49
+ } catch {
50
+ return null; // vanished mid-scan — the next pass sees the final state
51
+ }
52
+ const m = matchFrontmatterBlock(content);
53
+ if (!m) return null;
54
+ let fm;
55
+ try {
56
+ fm = yaml.load(m[1], { schema: yaml.JSON_SCHEMA });
57
+ } catch {
58
+ return null;
59
+ }
60
+ if (fm === null || typeof fm !== 'object' || Array.isArray(fm)) return null;
61
+ return { rel, ctx, fm, body: content.slice(m[0].length) };
62
+ }
63
+
64
+ // All *.md files under `root` (recursive), as install-relative paths. A missing dir
65
+ // yields nothing (a fresh install may not have every layer populated yet).
66
+ export async function walkMarkdown(installRoot, root) {
67
+ const out = [];
68
+ let entries;
69
+ try {
70
+ entries = await readdir(root, { withFileTypes: true });
71
+ } catch {
72
+ return out; // dir absent — nothing to walk
73
+ }
74
+ for (const e of entries) {
75
+ const abs = join(root, e.name);
76
+ if (e.isDirectory()) out.push(...(await walkMarkdown(installRoot, abs)));
77
+ else if (e.isFile() && e.name.endsWith('.md')) out.push(relative(installRoot, abs));
78
+ }
79
+ return out;
80
+ }
81
+
82
+ // Build the typed-object context for a file from its install-relative path.
83
+ // Domain objects: domains/{slug}/compiled/{typeDir}/…/{name}.md. Codex objects:
84
+ // codex/{personal|seed}/…/{name}.md (codex/INDEX.md is the map, not an object).
85
+ // Returns null for anything that is not a typed object.
86
+ export function contextFor(relPath) {
87
+ const parts = relPath.split(sep);
88
+ const name = basename(relPath, '.md');
89
+ if (parts[0] === 'domains' && parts[2] === 'compiled') {
90
+ // typeDir is the FULL sub-path between compiled/ and the file, so a nested object
91
+ // (compiled/decisions/archive/x.md) fails the type↔path check instead of passing
92
+ // as a flat one — the path schema is flat compiled/{type-dir}/{name}.md.
93
+ const typeDir = parts.slice(3, -1).join('/');
94
+ return { layer: 'domain', domain: parts[1], typeDir, codexKind: null, name };
95
+ }
96
+ if (parts[0] === 'codex') {
97
+ if (relPath === join('codex', 'INDEX.md')) return null; // the codex map, not an object
98
+ const kind = parts[1] === 'seed' || parts[1] === 'personal' ? parts[1] : null;
99
+ return { layer: 'codex', domain: null, typeDir: null, codexKind: kind, name };
100
+ }
101
+ return null;
102
+ }
103
+
104
+ // The install's typed-object file set: domains/*/compiled/ objects + every codex file.
105
+ // (The codex/INDEX.md map is filtered out downstream by contextFor returning null.)
106
+ export async function listObjectFiles(installRoot) {
107
+ return [
108
+ ...(await walkMarkdown(installRoot, join(installRoot, 'domains'))).filter(
109
+ (p) => p.split(sep)[2] === 'compiled',
110
+ ),
111
+ ...(await walkMarkdown(installRoot, join(installRoot, 'codex'))),
112
+ ];
113
+ }
114
+
115
+ // The RETRIEVAL-facing object set: every typed object EXCEPT the shipped seed library.
116
+ // codex/seed/ is quarantined OUT of retrieval (specs/compile-retrieve-loop.md
117
+ // §"Seed-vs-personal quarantine") — seed objects never enter the link/search index, so a
118
+ // seed can never surface in recall/query even if a downstream scope filter regresses, and
119
+ // a fresh install's index stays empty until the operator compiles their own work. Seed
120
+ // discoverability stays with codex/INDEX.md + lint. `validate` and `lint` deliberately keep
121
+ // scanning the FULL listObjectFiles set — seeds ARE contract-checked and lint-surfaced
122
+ // (never-adopted drop suggestions); only the retrieval indices use this filtered view.
123
+ export async function listRetrievableObjectFiles(installRoot) {
124
+ return (await listObjectFiles(installRoot)).filter((rel) => contextFor(rel)?.codexKind !== 'seed');
125
+ }