@tidyfactor/doc 1.3.0 → 1.9.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 (51) hide show
  1. package/.tidyfactor +3 -3
  2. package/CHANGELOG.md +103 -4
  3. package/README.ar.md +34 -8
  4. package/README.de.md +1 -1
  5. package/README.es.md +1 -1
  6. package/README.fa.md +1 -1
  7. package/README.fr.md +1 -1
  8. package/README.md +34 -8
  9. package/README.pt.md +1 -1
  10. package/README.zh.md +1 -1
  11. package/SKILL.md +28 -5
  12. package/bin/add-skill.js +44 -6
  13. package/brand.json +1 -1
  14. package/brand.yaml +10 -0
  15. package/manifest.json +216 -0
  16. package/package.json +4 -2
  17. package/references/commands/adr.md +25 -0
  18. package/references/commands/audit.md +15 -0
  19. package/references/commands/brief.md +16 -0
  20. package/references/commands/generate.md +7 -6
  21. package/references/commands/site.md +25 -23
  22. package/references/commands/vitepress.md +20 -0
  23. package/references/memory/20-brain-baas-integration.md +83 -0
  24. package/references/memory/adr-template.md +84 -0
  25. package/references/memory/changelog-rules.md +58 -0
  26. package/references/memory/collection-sources.md +48 -47
  27. package/references/memory/decision-points.md +72 -0
  28. package/references/memory/doc-templates.md +102 -73
  29. package/references/memory/doc-tree.md +38 -37
  30. package/references/memory/docsify-config.md +274 -273
  31. package/references/memory/git-doc-sync-hook.md +54 -0
  32. package/references/memory/mkdocs-config.md +171 -170
  33. package/references/memory/naming-conventions.md +40 -0
  34. package/references/memory/project-mindmap.md +66 -0
  35. package/references/memory/site-engines.md +32 -34
  36. package/references/memory/stacks/js-ts.md +47 -45
  37. package/references/memory/stacks/php.md +35 -33
  38. package/references/memory/stacks/react-vue-next.md +52 -50
  39. package/references/memory/tone-of-voice.md +31 -0
  40. package/references/memory/vitepress-config.md +174 -0
  41. package/references/workflows/audit.md +42 -0
  42. package/references/workflows/brief.md +105 -0
  43. package/references/workflows/collect.md +60 -25
  44. package/references/workflows/generate-adr.md +41 -0
  45. package/references/workflows/generate-changelog.md +52 -0
  46. package/references/workflows/init-docs.md +44 -18
  47. package/references/workflows/vitepress.md +57 -0
  48. package/scripts/audit_docs.py +190 -0
  49. package/scripts/clean_orphaned_assets.py +185 -0
  50. package/tools/build-skill.js +3 -0
  51. package/assets/og-default.png +0 -0
@@ -1,33 +1,35 @@
1
- # Memory: stacks/php
2
-
3
- Documentation conventions for PHP targets. Applies whenever the target's manifest is `composer.json` or files are `.php`.
4
-
5
- ## Inline comment format PHPDoc
6
-
7
- ```php
8
- /**
9
- * <one-line summary>
10
- *
11
- * <optional longer description>
12
- *
13
- * @param string $name Description of the parameter.
14
- * @param int|null $limit Description. Optional, defaults to null.
15
- * @return array<string, mixed> Description of the return shape.
16
- * @throws InvalidArgumentException When <condition, from error-patterns findings>.
17
- */
18
- ```
19
-
20
- - One blank-line-separated summary + description, then tags.
21
- - Always type-hint `@param`/`@return` even when the function itself is already typed — PHPDoc types can be more specific (e.g. `array<string, int>` vs. plain `array`).
22
- - `@throws` is mandatory whenever the error-patterns findings show this function throwing — never omit it to save space.
23
- - Class-level docblocks get `@package` only if the project already uses PSR-4 namespacing conventions that make it meaningful; skip otherwise.
24
-
25
- ## API reference formatting
26
-
27
- - Signatures shown as the actual PHP declaration line (with type hints), not a paraphrase: `public function createUser(string $email, ?int $roleId = null): User`
28
- - Nullable/union types shown exactly as declared (`?int`, `int|string`).
29
- - Static vs. instance methods both documented the same way note staticness in the signature itself, not as prose.
30
-
31
- ## What NOT to document inline
32
-
33
- - Private/protected helper methods with obvious single-purpose names don't need a full docblock — a one-line `// ` comment is enough, or none if truly self-evident. Full PHPDoc blocks are for the public API surface.
1
+ # Memory: stacks/php
2
+
3
+ <!-- last-verified: 2026-09-08 -->
4
+
5
+ Documentation conventions for PHP targets. Applies whenever the target's manifest is `composer.json` or files are `.php`.
6
+
7
+ ## Inline comment format — PHPDoc
8
+
9
+ ```php
10
+ /**
11
+ * <one-line summary>
12
+ *
13
+ * <optional longer description>
14
+ *
15
+ * @param string $name Description of the parameter.
16
+ * @param int|null $limit Description. Optional, defaults to null.
17
+ * @return array<string, mixed> Description of the return shape.
18
+ * @throws InvalidArgumentException When <condition, from error-patterns findings>.
19
+ */
20
+ ```
21
+
22
+ - One blank-line-separated summary + description, then tags.
23
+ - Always type-hint `@param`/`@return` even when the function itself is already typed PHPDoc types can be more specific (e.g. `array<string, int>` vs. plain `array`).
24
+ - `@throws` is mandatory whenever the error-patterns findings show this function throwing — never omit it to save space.
25
+ - Class-level docblocks get `@package` only if the project already uses PSR-4 namespacing conventions that make it meaningful; skip otherwise.
26
+
27
+ ## API reference formatting
28
+
29
+ - Signatures shown as the actual PHP declaration line (with type hints), not a paraphrase: `public function createUser(string $email, ?int $roleId = null): User`
30
+ - Nullable/union types shown exactly as declared (`?int`, `int|string`).
31
+ - Static vs. instance methods both documented the same way — note staticness in the signature itself, not as prose.
32
+
33
+ ## What NOT to document inline
34
+
35
+ - Private/protected helper methods with obvious single-purpose names don't need a full docblock — a one-line `// ` comment is enough, or none if truly self-evident. Full PHPDoc blocks are for the public API surface.
@@ -1,50 +1,52 @@
1
- # Memory: stacks/react-vue-next
2
-
3
- Component-level documentation conventions, layered on top of `js-ts.md` (still use JSDoc/TSDoc block syntax — this file adds what's specific to components, pages, and routes).
4
-
5
- ## Reactprops, not just function signature
6
-
7
- ```tsx
8
- /**
9
- * <one-line summary of what the component renders/does>
10
- */
11
- interface ButtonProps {
12
- /** Description of this prop. */
13
- label: string;
14
- /** Optional, defaults to 'primary'. */
15
- variant?: 'primary' | 'secondary';
16
- /** Called when clicked. */
17
- onClick?: () => void;
18
- }
19
- ```
20
-
21
- - Document props via the `interface`/`type` block (per-member comments), not a `@param` list on the component function — that's the idiomatic React pattern and what most tooling (Storybook, TypeDoc) expects.
22
- - Note default values from the actual destructured defaults or `defaultProps`, not assumed.
23
-
24
- ## Vue SFC `<script>` block comments + `defineProps`
25
-
26
- ```vue
27
- <script setup lang="ts">
28
- /**
29
- * <one-line summary>
30
- */
31
- defineProps<{
32
- /** Description. */
33
- label: string;
34
- /** Optional, defaults to 'primary'. */
35
- variant?: 'primary' | 'secondary';
36
- }>();
37
- </script>
38
- ```
39
-
40
- - For Options API components (no `<script setup>`), document each prop inside the `props: {}` object with a comment above it instead.
41
- - Emitted events (`defineEmits` / `this.$emit`) get documented the same way props do — name, payload type, when it fires (from code parsing + error-patterns findings if it's an error event).
42
-
43
- ## Next.js pages/routes get a route-level note, not just a component doc
44
-
45
- - For a page/route file, prepend a comment noting the route path, whether it's a Server or Client Component, and any `params`/`searchParams` it reads — this is route contract, not just component contract.
46
- - API routes (`route.ts`/`route.js` under `app/api/`, or `pages/api/`) are documented as API reference (`generate-api`, using `js-ts.md`'s function conventions for the handler), not as component docs.
47
-
48
- ## What NOT to document
49
-
50
- - Purely presentational/internal sub-components not exported from the module's public entry point: skip the full prop-table treatment unless they're complex enough that the error-patterns or persona-tracing findings flagged them as maintainer-relevant.
1
+ # Memory: stacks/react-vue-next
2
+
3
+ <!-- last-verified: 2026-09-08 -->
4
+
5
+ Component-level documentation conventions, layered on top of `js-ts.md` (still use JSDoc/TSDoc block syntax this file adds what's specific to components, pages, and routes).
6
+
7
+ ## React — props, not just function signature
8
+
9
+ ```tsx
10
+ /**
11
+ * <one-line summary of what the component renders/does>
12
+ */
13
+ interface ButtonProps {
14
+ /** Description of this prop. */
15
+ label: string;
16
+ /** Optional, defaults to 'primary'. */
17
+ variant?: 'primary' | 'secondary';
18
+ /** Called when clicked. */
19
+ onClick?: () => void;
20
+ }
21
+ ```
22
+
23
+ - Document props via the `interface`/`type` block (per-member comments), not a `@param` list on the component function — that's the idiomatic React pattern and what most tooling (Storybook, TypeDoc) expects.
24
+ - Note default values from the actual destructured defaults or `defaultProps`, not assumed.
25
+
26
+ ## Vue — SFC `<script>` block comments + `defineProps`
27
+
28
+ ```vue
29
+ <script setup lang="ts">
30
+ /**
31
+ * <one-line summary>
32
+ */
33
+ defineProps<{
34
+ /** Description. */
35
+ label: string;
36
+ /** Optional, defaults to 'primary'. */
37
+ variant?: 'primary' | 'secondary';
38
+ }>();
39
+ </script>
40
+ ```
41
+
42
+ - For Options API components (no `<script setup>`), document each prop inside the `props: {}` object with a comment above it instead.
43
+ - Emitted events (`defineEmits` / `this.$emit`) get documented the same way props do — name, payload type, when it fires (from code parsing + error-patterns findings if it's an error event).
44
+
45
+ ## Next.js pages/routes get a route-level note, not just a component doc
46
+
47
+ - For a page/route file, prepend a comment noting the route path, whether it's a Server or Client Component, and any `params`/`searchParams` it reads — this is route contract, not just component contract.
48
+ - API routes (`route.ts`/`route.js` under `app/api/`, or `pages/api/`) are documented as API reference (`generate-api`, using `js-ts.md`'s function conventions for the handler), not as component docs.
49
+
50
+ ## What NOT to document
51
+
52
+ - Purely presentational/internal sub-components not exported from the module's public entry point: skip the full prop-table treatment unless they're complex enough that the error-patterns or persona-tracing findings flagged them as maintainer-relevant.
@@ -0,0 +1,31 @@
1
+ <!-- last-verified: 2026-09-09 -->
2
+ # Memory: tone-of-voice
3
+
4
+ Authoritative tone of voice and technical writing standards for all documentation produced by `tidyfactor-doc`.
5
+
6
+ ## 1. Core Principles
7
+
8
+ 1. **Direct & Action-Oriented**:
9
+ - Start sentences with verbs where possible: *"Install dependencies with `npm install`"*, not *"You may want to proceed by running npm install"*.
10
+ - Eliminate filler words: avoid *"clearly"*, *"obviously"*, *"simply"*, *"just"*, *"as you know"*.
11
+
12
+ 2. **Zero Marketing Fluff**:
13
+ - Technical documentation is not promotional copywriting.
14
+ - Do NOT use exaggerated marketing adjectives like *"revolutionary"*, *"best-in-class"*, *"magical"*, *"effortless"*.
15
+ - State engineering facts, constraints, and verifiable trade-offs objectively.
16
+
17
+ 3. **Semantic Density & Token Efficiency**:
18
+ - Use structured tables for parameters, configuration options, and error codes rather than paragraphs of running text.
19
+ - Favor short, concise bullet points (≤ 15 words) over dense narrative prose.
20
+
21
+ 4. **Clarity Over Cleverness**:
22
+ - Code examples must be minimal, self-contained, and working out of the box.
23
+ - Always document error cases and expected exceptions, not just happy paths.
24
+
25
+ ## 2. Bilingual English & Arabic Standards
26
+
27
+ - **English**: Concise technical register (Imperative mood, active voice).
28
+ - **Arabic**:
29
+ - Clear Modern Standard Arabic (فصحى معاصرة رصينة ومباشرة).
30
+ - Use established technical terminology (e.g. "التوثيق البرمجي", "نقاط النهاية API", "سجل القرارات المعمارية ADR", "المزامنة الذرية").
31
+ - Preserve English code symbols and keyword references within markdown inline code blocks (`code`).
@@ -0,0 +1,174 @@
1
+ <!-- last-verified: 2026-09-09 -->
2
+ # Memory: VitePress Configuration Spec & Luxury Theme Architecture
3
+
4
+ Complete architectural specification for scaffolding, configuring, and styling production-grade documentation portals with VitePress, luxury typography, and full RTL layout parity.
5
+
6
+ ---
7
+
8
+ ## 1. Master ESM Configuration Schema (`docs/.vitepress/config.mjs`)
9
+
10
+ ```javascript
11
+ import { defineConfig } from 'vitepress';
12
+
13
+ export default defineConfig({
14
+ title: 'Project Name',
15
+ description: 'Production Documentation Portal',
16
+ head: [
17
+ ['link', { rel: 'icon', href: '/logo.png' }]
18
+ ],
19
+
20
+ locales: {
21
+ root: {
22
+ label: 'العربية',
23
+ lang: 'ar',
24
+ dir: 'rtl',
25
+ themeConfig: {
26
+ nav: [
27
+ { text: 'الرئيسية', link: '/' },
28
+ { text: 'دليل الاستخدام', link: '/user_manual.ar' },
29
+ { text: 'المواصفات المعمارية', link: '/specs/architecture_spec.ar' },
30
+ { text: 'GitHub', link: 'https://github.com/organization/repo' }
31
+ ],
32
+ sidebar: [
33
+ {
34
+ text: '🚀 البدء السريع',
35
+ items: [
36
+ { text: 'نظرة عامة', link: '/' },
37
+ { text: 'دليل التثبيت', link: '/guide/getting-started.ar' }
38
+ ]
39
+ }
40
+ ]
41
+ }
42
+ },
43
+ en: {
44
+ label: 'English',
45
+ lang: 'en',
46
+ link: '/en/',
47
+ themeConfig: {
48
+ nav: [
49
+ { text: 'Home', link: '/en/' },
50
+ { text: 'User Manual', link: '/user_manual.ar' }
51
+ ]
52
+ }
53
+ }
54
+ },
55
+
56
+ themeConfig: {
57
+ logo: '/logo.png',
58
+ siteTitle: 'Project Name',
59
+ search: {
60
+ provider: 'local'
61
+ },
62
+ footer: {
63
+ message: 'Released under Apache-2.0 License',
64
+ copyright: 'Copyright © 2026 Engineering Team'
65
+ }
66
+ }
67
+ });
68
+ ```
69
+
70
+ ---
71
+
72
+ ## 2. Luxury Design System Tokens (`docs/.vitepress/theme/custom.css`)
73
+
74
+ ```css
75
+ @import url('https://fonts.googleapis.com/css2?family=Alexandria:wght@400;500;600;700;800;900&family=Cairo:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');
76
+
77
+ :root {
78
+ --vp-font-family-base: 'Cairo', sans-serif;
79
+ --vp-font-family-headings: 'Alexandria', sans-serif;
80
+ --vp-font-family-mono: 'JetBrains Mono', monospace;
81
+ }
82
+
83
+ /* RTL Navbar Flex Order */
84
+ html[dir="rtl"] .VPNavBar .content-body {
85
+ display: flex !important;
86
+ flex-direction: row !important;
87
+ align-items: center !important;
88
+ width: 100%;
89
+ }
90
+ html[dir="rtl"] .VPNavBarTitle { order: 1 !important; margin-inline-end: 28px !important; }
91
+ html[dir="rtl"] .VPNavBarMenu { order: 2 !important; margin-inline-end: auto !important; }
92
+ html[dir="rtl"] .VPNavBarSearch { order: 3 !important; }
93
+ html[dir="rtl"] .VPNavBarTranslations { order: 4 !important; }
94
+ html[dir="rtl"] .VPNavBarAppearance { order: 5 !important; }
95
+ html[dir="rtl"] .VPNavBarSocialLinks { order: 6 !important; }
96
+
97
+ /* Hero Reading Direction in RTL: Text on Right, Logo on Left */
98
+ .VPHomeHero .container {
99
+ display: flex !important;
100
+ align-items: center !important;
101
+ justify-content: space-between !important;
102
+ }
103
+ html[dir="rtl"] .VPHomeHero .container { flex-direction: row !important; }
104
+ html[dir="rtl"] .VPHomeHero .main { order: 1 !important; text-align: right !important; flex: 1 1 60% !important; }
105
+ html[dir="rtl"] .VPHomeHero .image { order: 2 !important; flex: 1 1 40% !important; display: flex !important; justify-content: center !important; }
106
+
107
+ /* Single-Row Protected Hero Actions */
108
+ .VPHomeHero .actions {
109
+ display: flex !important;
110
+ flex-direction: row !important;
111
+ align-items: center !important;
112
+ gap: 14px !important;
113
+ flex-wrap: nowrap !important;
114
+ }
115
+ .VPButton {
116
+ min-height: 48px !important;
117
+ height: 48px !important;
118
+ padding: 0 24px !important;
119
+ border-radius: 14px !important;
120
+ font-family: 'Alexandria', sans-serif !important;
121
+ font-weight: 700 !important;
122
+ font-size: 0.95rem !important;
123
+ white-space: nowrap !important;
124
+ word-break: keep-all !important;
125
+ }
126
+
127
+ /* 3-Column Luxury Feature Cards (Column Collapse Fix) */
128
+ .VPFeatures .items {
129
+ display: flex !important;
130
+ flex-wrap: wrap !important;
131
+ margin: -10px !important;
132
+ }
133
+ .VPFeatures .item {
134
+ padding: 10px !important;
135
+ box-sizing: border-box !important;
136
+ width: 100% !important;
137
+ display: flex !important;
138
+ }
139
+ @media (min-width: 640px) { .VPFeatures .item { width: 50% !important; } }
140
+ @media (min-width: 960px) { .VPFeatures .item { width: 33.333333% !important; } }
141
+
142
+ .VPFeature {
143
+ border: 1px solid var(--vp-c-divider) !important;
144
+ border-radius: 20px !important;
145
+ background: var(--vp-c-bg-soft) !important;
146
+ backdrop-filter: blur(20px) !important;
147
+ padding: 28px !important;
148
+ width: 100% !important;
149
+ height: 100% !important;
150
+ box-sizing: border-box !important;
151
+ }
152
+ html[dir="rtl"] .VPFeature .title,
153
+ html[dir="rtl"] .VPFeature .details {
154
+ text-align: right !important;
155
+ direction: rtl !important;
156
+ unicode-bidi: plaintext !important;
157
+ }
158
+ ```
159
+
160
+ ---
161
+
162
+ ## 3. Quick Navigation Grid Markdown Template
163
+
164
+ ```markdown
165
+ ## 🧭 جدول المحتويات والمسارات السريعة
166
+
167
+ <div class="quick-nav-grid">
168
+
169
+ | 🚀 البدء والأدوات | 💼 التطبيقات وحزم العمل | 🏛️ المعمارية العميقة |
170
+ |---|---|---|
171
+ | • [دليل التثبيت](/guide/getting-started.ar)<br>• [مرجع الطرفية](/tools/cli.ar) | • [تطبيقات الإنتاجية](/apps/productivity.ar)<br>• [حزمة الأعمال](/apps/office-suite.ar) | • [بنية الذاكرة](/architecture/memory-and-search.ar)<br>• [المواصفات الفنية](/specs/architecture_spec.ar) |
172
+
173
+ </div>
174
+ ```
@@ -0,0 +1,42 @@
1
+ # Workflow: audit
2
+
3
+ One outcome: a deterministic documentation quality & hygiene audit report verifying zero credential leaks, zero banned machine paths, 100% relative link integrity, and valid CHANGELOG formatting.
4
+
5
+ ## Steps
6
+
7
+ 1. **Determine the target path**:
8
+ - If user specified a file or folder (e.g. `docs/`, `README.md`, `CHANGELOG.md`), audit that target.
9
+ - Otherwise, default to full documentation sweep: `docs/`, `README.md`, `README.ar.md`, `CHANGELOG.md`.
10
+
11
+ 2. **Run deterministic auditor**:
12
+ - Execute the native Python auditing tool:
13
+ ```bash
14
+ python scripts/audit_docs.py docs/
15
+ python scripts/audit_docs.py README.md
16
+ python scripts/audit_docs.py CHANGELOG.md
17
+ ```
18
+ - For machine-readable output or CI pipeline integration:
19
+ ```bash
20
+ python scripts/audit_docs.py docs/ --json
21
+ ```
22
+
23
+ 3. **Analyze findings**:
24
+ - **Critical issues (Score -30 each)**: Plaintext secrets, leaked API keys, database passwords, or private tokens.
25
+ - **High issues (Score -15 each)**: Banned absolute workstation paths (`file:///C:`, `\wamp64\www\`), broken relative markdown links pointing to missing files, missing CHANGELOG headers.
26
+ - **Low issues**: Non-standard changelog version headers or minor formatting irregularities.
27
+
28
+ 4. **Remediate detected issues**:
29
+ - Redact any sensitive tokens into safe RFC placeholders (`EXAMPLE_KEY_1234567890ABCDEFGH`).
30
+ - Fix broken relative links to point to valid paths or update link targets.
31
+ - Convert absolute filesystem URLs to clean relative markdown paths (`./docs/README.md`).
32
+
33
+ 5. **Re-run verification**:
34
+ - Re-execute the auditor until a clean score of **100/100 [PASS]** is achieved.
35
+
36
+ ## Validation checklist
37
+
38
+ - [ ] All target documentation files scanned by `scripts/audit_docs.py`
39
+ - [ ] Overall score is 100/100 (`passed: true`) with 0 critical and 0 high issues
40
+ - [ ] Zero sensitive tokens or credentials present across all scanned files
41
+ - [ ] All relative links verified to exist on disk (zero broken relative links)
42
+ - [ ] CHANGELOG.md conforms to Keep a Changelog v1.1.0 standard headers
@@ -0,0 +1,105 @@
1
+ # Workflow: brief
2
+
3
+ One outcome: a validated documentation architectural brief and local snapshot, establishing all governance parameters before scaffolding or code parsing begins.
4
+
5
+ ---
6
+
7
+ ## 📋 Step 0: Context Delta Resolution (CDL v2.0)
8
+
9
+ Before querying the user, deterministically evaluate the Context Delta formula:
10
+
11
+ $$\text{Unknowns} = \text{Required Decisions} - (\text{Discovered Facts} \cup \text{Brain KIs})$$
12
+
13
+ 1. **Local Auto-Sensing on Disk**:
14
+ - Inspect `package.json`, `composer.json`, `tsconfig.json` for stack identification.
15
+ - Check existing documentation markers (`mkdocs.yml`, `docs/index.html`, `docs/.doc-manifest.json`).
16
+ - Read `brand.yaml` (fallback `brand.json`) for project name, audience, and license.
17
+ - Check `.tidyfactor/doc-brief.snapshot.yaml`: if present and file hashes match (`track_staleness: true`), resolve all decisions immediately.
18
+ 2. **Fail-Open Brain MCP Acceleration**:
19
+ - Query `search_knowledge_base(query="documentation architecture", scope="project")`.
20
+ - If Brain MCP is absent, disabled, or empty, proceed with 0ms silent fallback.
21
+ 3. **Delta Evaluation**:
22
+ - If $\text{Unknowns} = \emptyset$: Proceed immediately to Step 2 (persist snapshot) with zero conversational overhead.
23
+ - If $\text{Unknowns} \neq \emptyset$: Proceed to Step 1 using the requested Operational Mode.
24
+
25
+ ---
26
+
27
+ ## 🧭 Step 1: Operational Mode Execution (Native Modal Wizard Contract)
28
+
29
+ > [!IMPORTANT]
30
+ > **Zero Static Text Questionnaires (`❌`)**:
31
+ > The agent is **STRICTLY FORBIDDEN** from outputting questions, choices, or debate trade-offs as plain written markdown text in the chat.
32
+ > The agent **MUST** invoke the platform's native interactive question tool (`ask_question` in Antigravity IDE) to render a structured modal wizard with selectable options and recommended defaults.
33
+
34
+ ---
35
+
36
+ ### [MODE A] 🎯 Smart 3-Round Protocol (الارتجال الذكي المقيد)
37
+ *Fast-track structured alignment via native modal wizards.*
38
+
39
+ - **Round 1: Purpose & Target Persona (D1 & D3)**:
40
+ - Invoke `ask_question`:
41
+ - Question 1: "ما هو النطاق الأساسي لتوثيق المشروع؟"
42
+ Options: `"(Recommended) full_codebase — توثيق شامل للـ API والمعمارية وأدلة التشغيل"`, `"api_surface_only — توثيق نقاط النهاية وواجهات الـ API فقط"`, `"internal_architecture — توثيق المعمارية وتهيئة المطورين الداخليين"`, `"end_user_docs — أدلة استخدام مبسطة للمستخدم النهائي"`
43
+ - Question 2: "ما هي شريحة القراء والتوجه اللغوي المستهدف؟"
44
+ Options: `"(Recommended) bilingual_developer — توثيق فني ثنائي باللغتين العربية والإنجليزية"`, `"api_consumer — توثيق تقني صارم بالإنجليزية لمستهلكي الـ API"`, `"internal_maintainer — توثيق معطيات القرارات وسياق المطورين"`, `"end_user — توثيق مبسط لغير التقنيين"`
45
+ - **Round 2: Architecture & Engine (D2 & D5)**:
46
+ - Invoke `ask_question`:
47
+ - Question 1: "ما هو محرك نشر وعرض التوثيق المعتمد؟"
48
+ Options: `"(Recommended) mkdocs_material — توليد موقع ثابت سريع مع بحث محلي ودعم ثنائي"`, `"docsify_spa — موقع تفاعلي فوري خفيف دون الحاجة لأي تجميع (Zero-Build)"`, `"static_markdown — ملفات Markdown خام قياسية تحت مجلد /docs"`
49
+ - Question 2: "ما هو عمق الاستقراء البرمجي المطلوب من الكود؟"
50
+ Options: `"(Recommended) full_5_dimensions — استقراء الأبعاد الخمسة (AST + Git History + Env + Personas + Errors)"`, `"signatures_and_types — مراجع الدوال والأنواع المصدرة فقط"`, `"architecture_and_rationale — المعمارية والحدود وسياق الـ Commits"`
51
+ - **Round 3: Hygiene & Safe Defaults (D4 & Escalation Gate)**:
52
+ - Invoke `ask_question`:
53
+ - Question: "ما هي سياسة حجب البيانات الحساسة والأمان؟"
54
+ Options: `"(Recommended) strict_zero_leak — حظر وتطهير آلي صارم لكافة المفاتيح وكلمات المرور وعناوين IP"`, `"public_sdk_redaction — حجب المسارات الداخلية مع اعتماد مسارات محاكاة"`, `"internal_audit_permissive — السماح بعناوين Loopback المحلية وعينات التهيئة"`
55
+ - **Escalation Gate (Modal Wizard)**:
56
+ - Invoke `ask_question`:
57
+ - Question: "اكتملت أبعاد التوثيق المبدئية. هل ترغب في اعتمادها فوراً أم تفعيل نمط المناظرة (Debate Mode) لتحدي القرارات؟"
58
+ - Options: `"(Recommended) اعتماد البنية المبدئية والبدء فوراً في التوثيق"`, `"تفعيل نمط المناظرة المعمارية (Debate Mode)"`
59
+
60
+ ---
61
+
62
+ ### [MODE B] 🔥 Relentless Debate & Interview (الاستجواب والمناظرة اللانهائية — Debate Mode)
63
+ *Deep architectural interrogation via step-by-step interactive question modals.*
64
+
65
+ - **Trigger**: Command `/debate`, explicit user prompt ("مناظرة" / "استجوبني"), or escalation from Round 3 of Mode A.
66
+ - **Modal Interrogation Protocol**:
67
+ - The agent poses **ONE architectural challenge at a time** strictly via `ask_question`.
68
+ - The question title encapsulates the dilemma (e.g. *"معضلة الصيانة اللغوية: هل نعتمد أتمتة صارمة لكافة اللغات أم نحصر التحديث الحي في لغتين أساسيتين؟"*).
69
+ - The options provide binary, concrete trade-offs with explicit costs:
70
+ - Option 1: `"(Recommended) حصر التحديث الحي المستمر على اللغتين الأساسيتين (AR/EN) واعتماد ملخصات تنفيذية للغات الأخرى"`
71
+ - Option 2: `"فرض أتمتة كاملة في الـ CI للغات الثماني بالتوازي مع إيقاف البناء عند أي نقص"`
72
+ - Each selection by the user leads to the next focused counter-question via `ask_question` exploring dependency and edge cases.
73
+ - **Termination Constraint**: Continues turn-by-turn until the user explicitly selects an option marked `اعتماد القرارات المعمارية وإنهاء المناظرة` or types `"END DEBATE"` / `"اعتماد"`.
74
+ - **Debate Artifact**: Emits formal synthesis at `docs/architectural_debate_synthesis.md` capturing all settled decisions, discarded alternatives, and technical rationale.
75
+
76
+ ---
77
+
78
+ ## 💾 Step 2: SSOT Local Persistence & Outbound Push
79
+
80
+ 1. **Write Local SSOT**:
81
+ - Write `.tidyfactor/doc-brief.snapshot.yaml` with resolved keys, mtimes, and hashes.
82
+ - Write `.tidyfactor/doc-brief.md` containing human-readable brief summary.
83
+ 2. **Outbound Push (`--sync-brain`)**:
84
+ - If `--sync-brain` flag was provided, invoke `extract_knowledge_item` to persist documentation metadata to sovereign Brain MCP.
85
+ - Local files remain the authoritative Single Source of Truth.
86
+
87
+ ---
88
+
89
+ ## 🎯 Step 3: Handoff
90
+
91
+ - If `/docs` directory is uninitialized ➔ Hand off to `workflows/init-docs.md`.
92
+ - If `/docs` exists and documentation needs generation ➔ Hand off to `workflows/collect.md` followed by `workflows/generate-*.md`.
93
+
94
+ ---
95
+
96
+ ## Validation checklist
97
+
98
+ - [ ] Context Delta Resolution computed before asking user any questions
99
+ - [ ] No questions asked for facts already discoverable from disk
100
+ - [ ] All interactive questions in Mode A and Mode B were presented exclusively via native modal wizard (ask_question), with zero static text surveys in chat
101
+ - [ ] Followed selected mode (Mode A terminated at Round 3; Mode B terminated only on "END DEBATE" / "اعتماد")
102
+ - [ ] If Mode B was executed, generated `docs/architectural_debate_synthesis.md`
103
+ - [ ] Local snapshot persisted to `.tidyfactor/doc-brief.snapshot.yaml`
104
+ - [ ] Human-readable brief saved to `.tidyfactor/doc-brief.md`
105
+ - [ ] No actual doc pages or API references written during this workflow
@@ -1,25 +1,60 @@
1
- # Workflow: collect
2
-
3
- One outcome: a structured findings file — `docs/.collected/<target>.md` — that `generate` can turn into any doc type without re-deriving facts from the codebase itself. `<target>` is the module, package, API surface, or component named by the request (or the whole project if none was named).
4
-
5
- ## Steps
6
-
7
- Run all five collection dimensions from `memory/collection-sources.md` against the target. Skip a dimension only if it genuinely doesn't apply (e.g., no Git history available for an uploaded snapshot) — note the skip and why, don't silently omit it.
8
-
9
- 1. **Code parsing.** Extract existing docblocks/comments, function/method/class signatures, exported types, and public surface area directly from source. Flag anything already documented inline so `generate` doesn't duplicate it.
10
- 2. **Commit history.** Read `git log` and any available PR descriptions for the target's files. Pull out *why* behind non-obvious code — rationale, past bugs fixed, deliberate tradeoffs — not just *what* changed.
11
- 3. **Runtime & environment.** Enumerate required environment variables, config files, software dependencies (with version constraints), and any stated hardware/resource limits. **MANDATORY**: Scrub and redact any actual secrets, production server IPs, database passwords, or private API tokens found in `.env` or config files—record only variable names, expected formats, and generic placeholder values.
12
- 4. **User persona tracing.** Identify who actually reads docs for this target — API consumers, internal maintainers, end-users — and note which facts matter to which persona (an internal maintainer needs the "why"; an API consumer needs the contract).
13
- 5. **Error patterns.** Collect how the code fails: thrown exceptions, error codes, logged failure messages, and how each is meant to be handled or surfaced. Scrub any sensitive runtime credentials or local workstation paths that appear inside logged messages.
14
-
15
- 6. **Write the findings** to `docs/.collected/<target>.md` as plain structured notes under five headings matching the dimensions above — this is source material for `generate`, not a finished doc, so skip prose polish.
16
- 7. **Update `docs/.doc-manifest.json`**: add `<target>` to the `collected` section with a timestamp.
17
-
18
- ## Validation checklist
19
-
20
- - [ ] `docs/.collected/<target>.md` exists and has content (or an explicit "not applicable" note) under all five dimension headings
21
- - [ ] Every fact traces to something actually found in the code, history, config, or logs — nothing inferred or assumed
22
- - [ ] Zero sensitive data leaked: all real API keys, passwords, private IPs, and secrets are replaced with safe generic placeholders
23
- - [ ] No local workstation drive paths (`C:\...`, `file:///...`) exist in findings; all paths are normalized to project-relative paths
24
- - [ ] `docs/.doc-manifest.json`'s `collected` section includes `<target>`
25
- - [ ] Findings are organized by dimension, not pre-formatted as any particular doc type
1
+ # Workflow: collect
2
+
3
+ One outcome: a structured findings file — `docs/.collected/<target>.md` — that `generate` can turn into any doc type without re-deriving facts from the codebase itself. `<target>` is the module, package, API surface, or component named by the request (or the whole project if none was named).
4
+
5
+ ---
6
+
7
+ ## 📋 Step 0: Context Delta Resolution & Auto-Sensing
8
+
9
+ Before prompting the user for scope or parameters, execute the mechanical resolution formula:
10
+
11
+ $$\text{Unknowns} = \text{Required Decisions} - (\text{Discovered Facts} \cup \text{Brain KIs})$$
12
+
13
+ 1. **Auto-Sensing on Disk**:
14
+ - Inspect `mkdocs.yml`, `docs/index.html`, `docs/.doc-manifest.json`, and codebase structure.
15
+ - For sources marked with `track_staleness: true`, compare hash/mtime against stored snapshot.
16
+ - Any parameter resolved from disk is removed from $\text{Unknowns}$.
17
+
18
+ 2. **Fail-Open Brain MCP Acceleration**:
19
+ - Check if architecture KIs exist via `search_knowledge_base(query="architecture routes apis", scope="project")`.
20
+ - If Brain MCP is absent, offline, or returns empty, proceed with 0ms delay directly to Step 1 without warnings.
21
+
22
+ ---
23
+
24
+ ## 🔍 Step 1: Codebase Collection Dimensions
25
+
26
+ Run all five collection dimensions from `memory/collection-sources.md` against the target:
27
+
28
+ 1. **Code parsing & Docblock Scraping**:
29
+ - **For PHP**: Scan for standard PHPDoc annotations (`@param [type] $var [description]`, `@return [type]`, `@throws [exception]`, `@deprecated`, `@var`). Extract class properties, public method signatures, interface implementations, and parameter typehints (`string`, `int`, `array`, `?callable`).
30
+ - **For JavaScript / TypeScript**: Scan for JSDoc / TSDoc annotations (`@param {type} name description`, `@returns {type}`, `@typedef`, `@template`, `@async`, `@example`). For TypeScript, extract exported interfaces, types, enums, and React/Vue component prop types directly from AST definitions.
31
+ - Cross-reference with `memory/stacks/php.md` or `memory/stacks/js-ts.md` to ensure exact standard compliance.
32
+ - Flag undocumented public surface area or stale docblocks where signature types diverge from comments.
33
+ 2. **Commit history**: Read `git log` and available PR descriptions for target files. Pull out *why* behind non-obvious code (tradeoffs, rationale, bug fixes).
34
+ 3. **Runtime & environment**: Enumerate required environment variables, config files, software dependencies (with version constraints), and resource limits. **MANDATORY**: Scrub and redact any actual secrets, production server IPs, database passwords, or private API tokens—record only variable names and generic placeholders.
35
+ 4. **User persona tracing**: Identify who reads docs for this target (API consumers, internal maintainers, end-users) and map facts accordingly.
36
+ 5. **Error patterns**: Collect how the code fails: thrown exceptions, error codes, logged failure messages, and resolution steps. Scrub local workstation paths.
37
+
38
+ ---
39
+
40
+ ## 💾 Step 2: Persist Findings & Outbound Push
41
+
42
+ 1. Write structured notes to `docs/.collected/<target>.md` under five headings matching the dimensions above.
43
+ 2. Update `docs/.doc-manifest.json` with `<target>` and timestamp.
44
+ 3. Save local snapshot `.tidyfactor/doc-brief.snapshot.yaml` for deterministic drift detection.
45
+ 4. **Anti-Dual-Write Outbound Push (`--sync-brain`)**:
46
+ - Local markdown files are the sole Single Source of Truth.
47
+ - When `--sync-brain` is explicitly provided, export extracted architecture facts to Brain MCP via `extract_knowledge_item`.
48
+
49
+ ---
50
+
51
+ ## Validation checklist
52
+
53
+ - [ ] Context Delta Resolution executed before prompting user.
54
+ - [ ] `docs/.collected/<target>.md` exists and has content under all five dimension headings.
55
+ - [ ] Every fact traces to verified code, history, config, or logs — zero hallucination.
56
+ - [ ] Zero sensitive data leaked: all real API keys, passwords, private IPs, and secrets replaced with generic placeholders.
57
+ - [ ] No local workstation drive paths (`C:\...`, `file:///...`) exist; all paths are normalized to project-relative paths.
58
+ - [ ] Deterministic audit passed via `python scripts/audit_docs.py docs/.collected/<target>.md`.
59
+ - [ ] `docs/.doc-manifest.json`'s `collected` section includes `<target>`.
60
+ - [ ] Findings organized by dimension, not pre-formatted as any particular doc type.